2020/c64/menu.asm

297 lines
11 KiB
NASM

// vim: filetype=kickass
.const PA = $dc00
.const PB = $dc01
.const DDRA = $dc02
.const DDRB = $dc03
* = * "Menu Routines"
//
// draw_menu
//
draw_menu:
lda $d018
and #%11110001
ora #%00000100
sta $d018
ldy #$fa + 1
sty $d020
sty $d021
!:
// TODO Compression for the characters
lda menu_characters + $0000 - 1, y
sta SCREEN_RAM + $0000 - 1, y
lda menu_characters + $00fa - 1, y
sta SCREEN_RAM + $00fa - 1, y
lda menu_characters + $01f4 - 1, y
sta SCREEN_RAM + $01f4 - 1, y
lda menu_characters + $02ee - 1, y
sta SCREEN_RAM + $02ee - 1, y
lda menu_colors + $0000 - 1, y
sta COLOR_RAM + $0000 - 1, y
lsr; lsr; lsr; lsr
sta COLOR_RAM + $00fa - 1, y
lda menu_colors + $00fa - 1, y
sta COLOR_RAM + $01f4 - 1, y
lsr; lsr; lsr; lsr
sta COLOR_RAM + $02ee - 1, y
dey
bne !-
rts
//
// menu_update
//
menu_update:
lda PA
lsr
bcs !not_up+
lda $07
sec
sbc #8
cmp #49
bcc !wait+
sta $07
jmp !wait+
!not_up:
lsr
bcs !not_down+
lda $07
clc
adc #08
cmp #242
bcs !wait+
sta $07
jmp !wait+
!not_down:
lsr
lsr
lsr
bcs !done+
sei
jsr clear_screen
lda $07
lsr; lsr; lsr
sec
sbc #6
asl
tay
// Modify JSR instruction to jump to the right day
lda !days+, y
sta !jump+ + 1
lda !days+ + 1, y
sta !jump+ + 2
!jump:
jsr !done+
!wait:
ldy #80
ldx #0
!:
!:
dex
bne !-
dey
bne !--
!done:
rts
!days:
.word day01 // 1
.word 0 // 2
.word 0 // 3
.word 0 // 4
.word day05 // 5
.word 0 // 6
.word 0 // 7
.word 0 // 8
.word 0
.word 0 // 9
.word 0
.word 0
.word 0 // 15
.word 0
.word 0 // 10
.word 0 // 14
.word 0
.word 0 // 11
.word 0 // 13
.word 0
.word 0 // 12
.word 0
.word 0
.word 0
.word 0
//
// setup_interrupt
//
setup_interrupt:
sei
SetRasterInterrupt(menu_irq)
move_16_imm($fffa, nmi_nop)
lda #$7f
sta $dc0d
sta $dd0d
lda #$01
sta $d019
sta $d01a
lda #$35
sta $01
cli
rts
menu_irq:
pha
txa
pha
tya
pha
StabilizeRaster()
ldy #11
sty $d020
sty $d021
ldy #90
!:
dey
bne !-
ldy #0
sty $d021
sty $d020
SetRasterInterrupt(menu_irq)
asl $d019
pla
tay
pla
tax
pla
rti
nmi_nop:
rti
.macro SetRasterInterrupt(address) {
move_16_imm($fffe, address)
lda $d011
and #$7f
sta $d011
lda $07
sta $d012
}
.macro StabilizeRaster() {
move_16_imm($fffe, stabilized_irq)
inc $d012
asl $d019
tsx
cli
nop
nop
nop
nop
nop
nop
nop
nop
nop
stabilized_irq:
txs
sei
ldx #6
!:
dex
bne !-
bit $00
lda $d012
cmp $d012
beq *+2
}
.align $0100
* = * "Menu Data"
menu_characters:
.byte $20,$20,$20,$20,$6f,$6f,$6f,$52,$52,$52,$46,$46,$46,$46,$42,$46,$46,$46,$46,$52,$52,$52,$6f,$6f,$6f,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$31,$2a,$2a
.byte $45,$45,$77,$77,$20,$2e,$27,$20,$20,$2d,$20,$20,$2d,$20,$20,$4d,$2d,$20,$2e,$27,$27,$68,$20,$68,$20,$77,$77,$45,$45,$44,$43,$40,$46,$52,$6f,$20,$20,$32,$20,$20
.byte $68,$20,$20,$68,$20,$27,$2e,$27,$2e,$20,$2d,$20,$20,$20,$2d,$20,$4d,$20,$2d,$27,$27,$3a,$20,$20,$68,$20,$68,$20,$20,$20,$68,$20,$20,$68,$20,$20,$20,$33,$20,$20
.byte $20,$20,$68,$20,$68,$20,$20,$68,$20,$27,$27,$2e,$2e,$27,$27,$27,$64,$1b,$1d,$2e,$27,$20,$20,$68,$20,$20,$20,$20,$68,$20,$20,$20,$68,$20,$68,$20,$20,$34,$20,$20
.byte $27,$2e,$20,$68,$20,$20,$68,$20,$20,$68,$20,$20,$64,$64,$6f,$4e,$63,$27,$27,$20,$20,$68,$20,$20,$68,$20,$20,$68,$20,$20,$20,$20,$20,$68,$20,$20,$20,$35,$2a,$2a
.byte $27,$20,$20,$2e,$2e,$6f,$6f,$6f,$6f,$6f,$4e,$77,$63,$63,$20,$20,$68,$20,$20,$68,$20,$20,$68,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20,$36,$20,$20
.byte $68,$20,$3a,$1b,$1d,$27,$2e,$20,$20,$20,$68,$20,$68,$20,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$37,$20,$20
.byte $20,$20,$20,$27,$2e,$4d,$20,$68,$20,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$68,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$38,$20,$20
.byte $20,$20,$68,$20,$20,$20,$4d,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$68,$20,$4d,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$39,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$4d,$20,$68,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$68,$20,$20,$2e,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$4d,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20,$3a,$27,$27,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$4d,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$6f,$6f,$64,$64,$68,$20,$27,$2e,$20,$2c,$20,$31,$35,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$4d,$20,$68,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$68,$20,$63,$63,$4d,$20,$20,$3a,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$4d,$20,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$2e,$4d,$27,$20,$2c,$20,$20,$31,$30,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$4d,$20,$20,$20,$2e,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$27,$2e,$1b,$1d,$20,$2c,$20,$31,$34,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$4d,$27,$27,$2c,$3a,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20,$64,$4e,$27,$2e,$2e,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$3a,$1b,$1d,$2e,$2e,$27,$20,$20,$20,$20,$20,$20,$20,$20,$20,$4e,$63,$68,$20,$20,$20,$27,$20,$31,$31,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$27,$27,$4d,$64,$64,$20,$20,$68,$20,$20,$20,$20,$20,$4e,$20,$20,$20,$20,$20,$20,$20,$20,$31,$33,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$63,$63,$4d,$64,$64,$20,$20,$20,$20,$4e,$68,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$63,$63,$4d,$64,$64,$4e,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$31,$32,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$63,$63,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$68,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
.byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$2e,$20,$2e,$2e,$20,$20,$20,$2e,$27,$20,$2e,$2e,$20,$20,$20,$20,$20,$20,$20,$20,$20
menu_colors:
.byte $6f, $0e, $6e, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $6e, $0e, $0e, $02, $0e, $0e, $0e, $0e, $0e // 0;00 - 0;20 | 6;10 - 6;30
.byte $0e, $0e, $0e, $0e, $0e, $00, $00, $f0, $00, $00, $00, $00, $00, $50, $50, $10, $e0, $6f, $07, $07 // 0;20 - 1;00 | 6;30 - 7;10
.byte $0e, $0e, $0e, $0e, $0e, $01, $61, $0e, $0e, $61, $00, $00, $01, $00, $01, $01, $c1, $0e, $01, $01 // 1;00 - 1;20 | 7;10 - 7;30
.byte $01, $06, $00, $c6, $0e, $0e, $0e, $fe, $0e, $0e, $0e, $0e, $6e, $0e, $0e, $00, $10, $0f, $00, $60 // 1;20 - 2;00 | 7;30 - 8;10
.byte $06, $0e, $0e, $06, $0e, $01, $01, $01, $01, $0e, $01, $00, $00, $00, $01, $0e, $01, $0e, $01, $b1 // 2;00 - 2;20 | 8;10 - 8;30
.byte $01, $01, $00, $00, $06, $00, $06, $00, $00, $00, $06, $03, $03, $06, $03, $60, $00, $1f, $00, $00 // 2;20 - 3;00 | 8;30 - 9;10
.byte $0e, $0e, $06, $0e, $06, $0e, $0e, $06, $0e, $01, $01, $01, $01, $01, $01, $c1, $01, $01, $01, $01 // 3;00 - 3;20 | 9;10 - 9;30
.byte $01, $00, $00, $c6, $00, $00, $00, $f0, $06, $00, $00, $00, $06, $0e, $06, $00, $00, $0f, $10, $00 // 3;20 - 4;00 | 9;30 - 10;10
.byte $65, $05, $00, $06, $0e, $0e, $06, $0e, $0e, $06, $01, $01, $01, $01, $01, $01, $01, $01, $b1, $00 // 4;00 - 4;20 | 10;10 - 10;30
.byte $00, $b6, $00, $00, $56, $00, $00, $06, $00, $00, $00, $00, $00, $06, $00, $00, $00, $0f, $07, $17 // 4;20 - 5;00 | 10;30 - 11;10
.byte $05, $00, $00, $05, $05, $01, $01, $01, $01, $01, $01, $01, $01, $b1, $01, $00, $06, $00, $00, $06 // 5;00 - 5;20 | 11;10 - 11;30
.byte $00, $50, $56, $50, $00, $00, $00, $00, $00, $06, $00, $00, $00, $00, $00, $00, $00, $0f, $00, $60 // 5;20 - 6;00 | 11;30 - 12;10
.byte $16, $00, $05, $01, $01, $05, $05, $05, $00, $00 // 6;00 - 6;10 | 12;10 - 12;20
.byte $00, $00, $00, $00, $00, $01, $f1, $f1, $01, $0b, $00, $05, $05, $0e, $05, $00, $0b, $0b, $00, $00 // 12;20 - 13;00 | 18;30 - 19;10
.byte $00, $00, $00, $00, $00, $00, $60, $10, $10, $10, $10, $11, $00, $06, $00, $00, $10, $60, $00, $00 // 13;00 - 13;20 | 19;10 - 19;30
.byte $00, $0b, $00, $00, $60, $0b, $01, $01, $01, $01, $00, $00, $05, $0e, $0b, $00, $00, $00, $00, $00 // 13;20 - 14;00 | 19;30 - 20;10
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $06, $10, $10, $11, $10, $10, $10, $06, $00, $00, $00 // 14;00 - 14;20 | 20;10 - 20;30
.byte $00, $00, $00, $01, $00, $00, $f0, $f0, $00, $05, $01, $05, $0e, $05, $00, $00, $0f, $0f, $00, $00 // 14;20 - 15;00 | 20;30 - 21;10
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $60, $11, $10, $00, $00, $05, $00, $00 // 15;00 - 15;20 | 21;10 - 21;30
.byte $00, $00, $60, $00, $00, $06, $00, $00, $00, $05, $05, $01, $01, $0e, $05, $00, $0f, $0f, $00, $00 // 15;20 - 16;00 | 21;30 - 22;10
.byte $00, $00, $00, $00, $00, $00, $00, $60, $00, $10, $00, $06, $00, $00, $01, $05, $05, $05, $05, $00 // 16;00 - 16;20 | 22;10 - 22;30
.byte $00, $06, $00, $00, $00, $00, $00, $00, $00, $01, $01, $05, $05, $05, $00, $00, $00, $00, $00, $00 // 16;20 - 17;00 | 22;30 - 23;10
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $10, $10, $10, $00, $05, $01, $01, $05, $05, $05, $00 // 17;00 - 17;20 | 23;10 - 23;30
.byte $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $06, $00, $00, $00, $05, $00, $0f, $0f, $00, $00 // 17;20 - 18;00 | 23;30 - 24;10
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $50, $e0, $50, $50, $00, $05, $05, $51, $51, $01, $50 // 18;00 - 18;20 | 24;10 - 24;30
.byte $50, $06, $00, $00, $00, $00, $00, $01, $00, $00 // 18;20 - 18;30 | 24;30 - 25;00