1822 lines
24 KiB
ArmAsm
1822 lines
24 KiB
ArmAsm
.feature c_comments
|
|
.include "../../build/loadersymbols-c64.inc"
|
|
|
|
.ZEROPAGE
|
|
.org $10
|
|
bmp_delay: .res 1
|
|
bmp_addr: .res 2
|
|
bmp_ptr: .res 2
|
|
scr_ptr_lo: .res 1
|
|
scr_ptr: .res 2
|
|
cram_ptr: .res 2
|
|
chr_count: .res 1
|
|
vbl: .res 1
|
|
frame: .res 1
|
|
cur_frame: .res 1
|
|
frame_delay: .res 1
|
|
frame_until: .res 1
|
|
text_ptr: .res 2
|
|
timer: .res 2
|
|
timer_limit: .res 2
|
|
timer_reached: .res 2
|
|
timer_mode: .res 1
|
|
temp: .res 3
|
|
|
|
aart_lz_buffer := $fd00
|
|
.include "lz_zp.asm"
|
|
|
|
CODE_START_ADDR = $e000
|
|
|
|
.segment "CODE"
|
|
|
|
ZP=$e0
|
|
offset = ZP+0
|
|
ZX0_src = ZP+2
|
|
ZX0_dst = ZP+4
|
|
bitr = ZP+6
|
|
pntr = ZP+7
|
|
|
|
|
|
.org $080d
|
|
|
|
copy_start:
|
|
sei
|
|
lda #$35
|
|
sta $01
|
|
|
|
lda #<CODE_START_ADDR
|
|
sta $fc
|
|
lda #>CODE_START_ADDR
|
|
sta $fd
|
|
|
|
lda #<code_start
|
|
sta $fa
|
|
lda #>code_start
|
|
sta $fb
|
|
|
|
ldy #0
|
|
ldx #>(code_end-CODE_START_ADDR)
|
|
beq :+++
|
|
:
|
|
lda ($fa), y
|
|
sta ($fc), y
|
|
iny
|
|
bne :-
|
|
inc $fb
|
|
inc $fd
|
|
dex
|
|
bne :-
|
|
beq :+
|
|
:
|
|
lda ($fa), y
|
|
sta ($fc), y
|
|
iny
|
|
:
|
|
cpy #<(code_end-CODE_START_ADDR)
|
|
bne :--
|
|
|
|
lda #$36
|
|
sta $01
|
|
cli
|
|
jsr install
|
|
sei
|
|
lda #$35
|
|
sta $01
|
|
jmp CODE_START_ADDR
|
|
|
|
.res loadraw - *
|
|
.incbin "../../build/loader-c64.prg", 2
|
|
|
|
.res install - *
|
|
.incbin "../../build/install-c64.prg", 2
|
|
|
|
code_start:
|
|
.org CODE_START_ADDR
|
|
|
|
sei
|
|
|
|
ldx #<fontname
|
|
ldy #>fontname
|
|
jsr loadraw
|
|
|
|
lda #$34
|
|
sta $01
|
|
|
|
ldx #0
|
|
:
|
|
lda $8000, x
|
|
sta $d800, x
|
|
eor #$ff
|
|
sta $c00, x
|
|
lda $8100, x
|
|
sta $d900, x
|
|
eor #$ff
|
|
sta $d00, x
|
|
inx
|
|
bne :-
|
|
|
|
lda #0
|
|
tax
|
|
:
|
|
.repeat 4, I
|
|
sta $d000+(I*250), x
|
|
.endrepeat
|
|
inx
|
|
cpx #250
|
|
bne :-
|
|
|
|
lda #$35
|
|
sta $01
|
|
|
|
lda #0
|
|
sta ZX0_dst+0
|
|
|
|
ldx #<badguy
|
|
ldy #>badguy
|
|
jsr load_8000_zx02_2000
|
|
|
|
lda #127
|
|
sta $dc0d
|
|
|
|
and $d011
|
|
sta $d011
|
|
|
|
lda $dc0d
|
|
lda $dd0d
|
|
|
|
lda #<irq_badguy
|
|
sta $fffe
|
|
lda #>irq_badguy
|
|
sta $ffff
|
|
|
|
lda #$1b
|
|
sta $d011
|
|
lda #$d0
|
|
sta $d012
|
|
|
|
lda #1
|
|
sta $d01a
|
|
sta bmp_delay
|
|
jsr init_bmp
|
|
|
|
lda #0
|
|
sta vbl
|
|
|
|
cli
|
|
|
|
lda #64
|
|
sta frame_delay
|
|
jsr wait_loop
|
|
|
|
jsr intro
|
|
|
|
lda #$0b
|
|
sta $d011
|
|
|
|
sei
|
|
ldx #<introname
|
|
ldy #>introname
|
|
lda #$10
|
|
jsr load_8000_zx02
|
|
|
|
ldx #<sidname
|
|
ldy #>sidname
|
|
jsr loadraw
|
|
|
|
ldx #<towername
|
|
ldy #>towername
|
|
jsr loadraw
|
|
|
|
lda #<fake_kernal_irq
|
|
sta $fffe
|
|
lda #>fake_kernal_irq
|
|
sta $ffff
|
|
|
|
lda #1
|
|
sta $d01a
|
|
|
|
jsr run_nufli_bmp
|
|
sei
|
|
jsr init_2x
|
|
lda #$0b
|
|
sta $d011
|
|
|
|
jsr clr_txt
|
|
ldx #<story_writ
|
|
ldy #>story_writ
|
|
jsr write_txt3
|
|
ldx #$30
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #1
|
|
sta timer_mode
|
|
|
|
lda #$20
|
|
jsr zx02_8000
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
ldx #$b8
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #2
|
|
sta timer_mode
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
jsr init_bmp
|
|
|
|
lda #0
|
|
sta vbl
|
|
|
|
lda #$11
|
|
sta frame_until
|
|
jsr wait_frame_until_2x
|
|
|
|
ldx #$6c
|
|
:
|
|
jsr wait_frame
|
|
jsr wait_frame
|
|
dex
|
|
bpl :-
|
|
|
|
lda #$0b
|
|
sta $d011
|
|
|
|
jsr clr_txt
|
|
ldx #<scenario_writ
|
|
ldy #>scenario_writ
|
|
jsr write_txt2
|
|
ldx #$80
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #1
|
|
sta timer_mode
|
|
|
|
ldx #<towerbeamname
|
|
ldy #>towerbeamname
|
|
jsr load_8000_zx02_2000
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
ldx #$90
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #2
|
|
sta timer_mode
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
jsr init_bmp
|
|
|
|
lda #0
|
|
sta vbl
|
|
|
|
lda #$0d
|
|
sta frame_until
|
|
jsr wait_frame_until_2x
|
|
lda bmp_addr
|
|
sta temp
|
|
lda bmp_addr+1
|
|
sta temp+1
|
|
lda cur_frame
|
|
sta temp+2
|
|
|
|
ldx #17
|
|
:
|
|
txa
|
|
pha
|
|
lda temp+2
|
|
sta cur_frame
|
|
lda temp
|
|
sta bmp_addr
|
|
lda temp+1
|
|
sta bmp_addr+1
|
|
lda #$0d+3
|
|
sta frame_until
|
|
jsr wait_frame_until_2x
|
|
pla
|
|
tax
|
|
dex
|
|
bpl :-
|
|
|
|
lda #$0b
|
|
sta $d011
|
|
|
|
jsr clr_txt
|
|
ldx #<prog_writ
|
|
ldy #>prog_writ
|
|
jsr write_txt2
|
|
ldx #$a8
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #1
|
|
sta timer_mode
|
|
|
|
ldx #<fieldname
|
|
ldy #>fieldname
|
|
jsr load_8000_zx02_2000
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
ldx #$48
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #2
|
|
sta timer_mode
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
jsr init_bmp
|
|
|
|
lda #0
|
|
sta vbl
|
|
|
|
lda #$08
|
|
sta frame_until
|
|
jsr wait_frame_until_2x
|
|
lda bmp_addr
|
|
sta temp
|
|
lda bmp_addr+1
|
|
sta temp+1
|
|
lda cur_frame
|
|
sta temp+2
|
|
|
|
ldx #2
|
|
:
|
|
txa
|
|
pha
|
|
lda temp+2
|
|
sta cur_frame
|
|
lda temp
|
|
sta bmp_addr
|
|
lda temp+1
|
|
sta bmp_addr+1
|
|
lda #$08+8
|
|
sta frame_until
|
|
jsr wait_frame_until_2x
|
|
pla
|
|
tax
|
|
dex
|
|
bpl :-
|
|
|
|
|
|
lda #0
|
|
sta vbl
|
|
lda #$27
|
|
sta frame_until
|
|
jsr wait_frame_until_2x
|
|
|
|
ldx #25
|
|
:
|
|
jsr wait_frame
|
|
dex
|
|
bpl :-
|
|
|
|
lda #$0b
|
|
sta $d011
|
|
|
|
jsr clr_txt
|
|
ldx #<gart_writ
|
|
ldy #>gart_writ
|
|
jsr write_txt5
|
|
ldx #$80
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #1
|
|
sta timer_mode
|
|
|
|
ldx #<fallingstarname
|
|
ldy #>fallingstarname
|
|
jsr load_8000_zx02_2000
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
ldx #$48
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #2
|
|
sta timer_mode
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
jsr init_bmp
|
|
|
|
lda #$1d
|
|
sta frame_until
|
|
jsr wait_frame_until_2x
|
|
|
|
ldx #5
|
|
:
|
|
jsr wait_frame
|
|
dex
|
|
bpl :-
|
|
|
|
lda #$0b
|
|
sta $d011
|
|
|
|
jsr clr_txt
|
|
ldx #<music_writ
|
|
ldy #>music_writ
|
|
jsr write_txt4
|
|
ldx #$80
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #1
|
|
sta timer_mode
|
|
|
|
ldx #<lilianame
|
|
ldy #>lilianame
|
|
jsr load_8000_zx02_2000
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
ldx #$10
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #8*11
|
|
sta timer
|
|
lda #2
|
|
sta timer_mode
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
ldx #$c4
|
|
ldy #$01
|
|
jsr init_timer
|
|
|
|
jsr init_bmp
|
|
|
|
lda #$08
|
|
sta frame_until
|
|
jsr wait_frame_until_2x
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
lda #$0b
|
|
sta $d011
|
|
|
|
jsr clr_txt
|
|
ldx #<scene_writ
|
|
ldy #>scene_writ
|
|
jsr write_txt3
|
|
ldx #$80
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #1
|
|
sta timer_mode
|
|
|
|
ldx #<liliaheroname
|
|
ldy #>liliaheroname
|
|
jsr load_8000_zx02_2000
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
ldx #$20
|
|
ldy #$01
|
|
jsr init_timer
|
|
lda #2
|
|
sta timer_mode
|
|
|
|
:
|
|
lda timer_reached
|
|
beq :-
|
|
|
|
part_9:
|
|
; $0400-$07ff buffer 0 tilemap
|
|
; $2000-$3fff buffer 0 bitmap
|
|
; $4000-$5fff buffer 1 bitmap
|
|
; $6000-$63ff buffer 1 tilemap
|
|
; $6400-$6417 next buffer CRAM
|
|
; $7000-$77ff tileset bitmap
|
|
; $7800-$78ff tileset tile colors
|
|
; $7900-$79ff tileset CRAM colors
|
|
; $9000- compressed tilemap
|
|
ldx #<islandname
|
|
ldy #>islandname
|
|
lda #$70
|
|
jsr load_8000_zx02
|
|
ldx #<islandmapname
|
|
ldy #>islandmapname
|
|
jsr loadraw
|
|
ldx #0
|
|
ldy #$90
|
|
jsr LZ_init_decomp
|
|
|
|
lda #0
|
|
sta $d011
|
|
jsr clear_2bufs
|
|
|
|
; set up sprites to cover scrolling
|
|
lda #$ff
|
|
ldx #0
|
|
: sta $2000,x
|
|
sta $4000,x
|
|
inx
|
|
bne :-
|
|
.repeat 4, I
|
|
ldx #I*48+$58
|
|
stx $d000+I*2
|
|
stx $d008+I*2
|
|
.endrepeat
|
|
ldx #6
|
|
:
|
|
lda #$42
|
|
sta $d001,x
|
|
lda #$d7
|
|
sta $d009,x
|
|
dex
|
|
dex
|
|
bpl :-
|
|
ldx #7
|
|
:
|
|
lda #$80
|
|
sta $07f8,x
|
|
lda #0
|
|
sta $63f8,x
|
|
sta $d027,x
|
|
dex
|
|
bpl :-
|
|
stx $d01d
|
|
stx $d015
|
|
inx
|
|
stx $d010
|
|
stx $d017
|
|
stx $d01b
|
|
stx $d01c
|
|
stx frame
|
|
|
|
lda #$18
|
|
sta $d018
|
|
lda #<((17+4)*40+$408)
|
|
sta text_ptr
|
|
lda #>((17+4)*40+$408)
|
|
sta text_ptr+1
|
|
ldx #16
|
|
:
|
|
lda #0
|
|
lda text_ptr
|
|
sec
|
|
sbc #40
|
|
sta text_ptr
|
|
sta scr_ptr
|
|
sta cram_ptr
|
|
sta bmp_ptr
|
|
lda text_ptr+1
|
|
sbc #0
|
|
sta text_ptr+1
|
|
sta scr_ptr+1
|
|
; carry is always set here
|
|
adc #$d8-$04-1
|
|
sta cram_ptr+1
|
|
adc #<(($20>>3)-$d8)
|
|
asl bmp_ptr
|
|
rol a
|
|
asl bmp_ptr
|
|
rol a
|
|
asl bmp_ptr
|
|
rol a
|
|
sta bmp_ptr+1
|
|
stx temp+1
|
|
jsr drawrow
|
|
ldx temp+1
|
|
dex
|
|
bpl :-
|
|
lda #0
|
|
sta cram_ptr
|
|
lda #$64
|
|
sta cram_ptr+1
|
|
:
|
|
lda $d011
|
|
bpl :-
|
|
lda #$38
|
|
sta $d011
|
|
lda #$18
|
|
sta $d016
|
|
lda #3
|
|
sta timer_mode
|
|
@loop:
|
|
lda #0
|
|
sta vbl
|
|
lda frame
|
|
cmp #$e0 ; TODO
|
|
bcc :+
|
|
jmp @finish
|
|
:
|
|
and #1
|
|
tax
|
|
jsr copybuf
|
|
jsr drawrow
|
|
:
|
|
lda vbl
|
|
cmp #32
|
|
bcc :-
|
|
; B U M R U S H C R A M C O P Y F U N K
|
|
ldy #23
|
|
: .repeat 16, I
|
|
lda $d808+(19-I)*40,y
|
|
sta $d808+(20-I)*40,y
|
|
.endrepeat
|
|
lda $6400,y
|
|
sta $d808+4*40,y
|
|
dey
|
|
bpl :-
|
|
inc frame
|
|
lda frame
|
|
lsr a
|
|
lda #$18
|
|
ldx #3
|
|
bcc :+
|
|
lda #$80
|
|
ldx #2
|
|
:
|
|
sta $d018
|
|
stx $dd00
|
|
jmp @loop
|
|
|
|
@finish:
|
|
lda #0
|
|
sta timer_mode
|
|
; TODO is there a delay here
|
|
|
|
part_10:
|
|
jmp *
|
|
|
|
drawrow:
|
|
ldy #0
|
|
charloop:
|
|
sty temp
|
|
lda #$70>>3
|
|
sta bmp_addr+1
|
|
jsr LZ_get_byte
|
|
tax
|
|
asl a
|
|
rol bmp_addr+1
|
|
asl a
|
|
rol bmp_addr+1
|
|
asl a
|
|
rol bmp_addr+1
|
|
sta bmp_addr
|
|
ldy #0
|
|
.repeat 8, I
|
|
lda (bmp_addr),y
|
|
sta (bmp_ptr),y
|
|
iny
|
|
.endrepeat
|
|
clc
|
|
lda bmp_ptr
|
|
adc #8
|
|
sta bmp_ptr
|
|
bne :+
|
|
inc bmp_ptr+1
|
|
:
|
|
ldy temp
|
|
lda $7800,x
|
|
sta (scr_ptr),y
|
|
lda $7900,x
|
|
sta (cram_ptr),y
|
|
iny
|
|
cpy #24
|
|
bne charloop
|
|
rts
|
|
|
|
intro:
|
|
lda #0
|
|
jsr sfx_init
|
|
|
|
lda #7
|
|
sta frame_until
|
|
jsr wait_frame_until
|
|
|
|
lda #64
|
|
sta frame_delay
|
|
jsr wait_loop
|
|
|
|
lda #1
|
|
jsr sfx_init
|
|
|
|
ldx #<darmtower_txt
|
|
ldy #>darmtower_txt
|
|
jsr upload_text
|
|
ldx #<(darmtower_txt+40)
|
|
ldy #>(darmtower_txt+40)
|
|
jsr upload_text_bottom
|
|
|
|
lda #50*5
|
|
sta frame_delay
|
|
jsr wait_loop
|
|
|
|
ldx #<empty_txt
|
|
ldy #>empty_txt
|
|
jsr upload_text
|
|
ldx #<empty_txt
|
|
ldy #>empty_txt
|
|
jsr upload_text_bottom
|
|
|
|
lda #$0d
|
|
sta frame_until
|
|
jsr wait_frame_until
|
|
|
|
ldx #<adol_win
|
|
ldy #>adol_win
|
|
jsr upload_text
|
|
ldx #<(adol_win+40)
|
|
ldy #>(adol_win+40)
|
|
jsr upload_text_bottom
|
|
|
|
lda #50*5
|
|
sta frame_delay
|
|
jsr wait_loop
|
|
|
|
ldx #<too_bad_txt
|
|
ldy #>too_bad_txt
|
|
jsr upload_text
|
|
ldx #<empty_txt
|
|
ldy #>empty_txt
|
|
jsr upload_text_bottom
|
|
|
|
lda #50*5
|
|
sta frame_delay
|
|
jsr wait_loop
|
|
|
|
ldx #<empty_txt
|
|
ldy #>empty_txt
|
|
jsr upload_text
|
|
|
|
lda #$13
|
|
sta frame_until
|
|
jsr wait_frame_until
|
|
|
|
lda #0
|
|
jsr sfx_init
|
|
|
|
lda #$1a
|
|
sta frame_until
|
|
jsr wait_frame_until
|
|
|
|
lda #120
|
|
sta frame_delay
|
|
jsr wait_loop
|
|
rts
|
|
|
|
wait_frame:
|
|
@loop:
|
|
bit $d011
|
|
bpl @loop
|
|
@loop2:
|
|
bit $d011
|
|
bmi @loop2
|
|
rts
|
|
|
|
init_2x:
|
|
lda #127
|
|
sta $dc0d
|
|
|
|
and $d011
|
|
sta $d011
|
|
|
|
lda $dc0d
|
|
lda $dd0d
|
|
|
|
lda #<irq_music
|
|
sta $fffe
|
|
lda #>irq_music
|
|
sta $ffff
|
|
|
|
lda #$0b
|
|
sta $d011
|
|
lda #$00
|
|
sta $d012
|
|
|
|
:
|
|
bit $d011
|
|
bpl :-
|
|
:
|
|
bit $d011
|
|
bmi :-
|
|
lda #51
|
|
:
|
|
cmp $d012
|
|
bne :-
|
|
|
|
lda #0
|
|
sta $d01a
|
|
sta $dc0e
|
|
|
|
lda #$63; <(985248/100)
|
|
sta $dc04
|
|
lda #$26; >(985248/100)
|
|
sta $dc05
|
|
lda #$11
|
|
sta $dc0e
|
|
|
|
lda $dc0d
|
|
and #$81
|
|
sta $dc0d
|
|
|
|
lda #$40
|
|
sta $dc0c
|
|
|
|
lda #$81
|
|
sta $dc0d
|
|
|
|
@loop:
|
|
bit $d011
|
|
bpl @loop
|
|
@loop2:
|
|
bit $d011
|
|
bmi @loop2
|
|
cli
|
|
rts
|
|
|
|
init_timer:
|
|
lda #0
|
|
sta timer_reached
|
|
sta timer_mode
|
|
sta timer
|
|
sta timer+1
|
|
stx timer_limit
|
|
sty timer_limit+1
|
|
rts
|
|
|
|
fade_cols:
|
|
.byte 0, 0
|
|
.byte $0, $0, $0, $0, $b, $c, $f, $1
|
|
.res 32-10, $1
|
|
|
|
irq_music:
|
|
pha
|
|
txa
|
|
pha
|
|
tya
|
|
pha
|
|
|
|
lda $dd00
|
|
and #3
|
|
sta @dd00_arc+1
|
|
and #3
|
|
sta $dd00
|
|
|
|
inc vbl
|
|
|
|
;inc $d020
|
|
jsr $a003
|
|
;dec $d020
|
|
|
|
lda timer_mode
|
|
cmp #1
|
|
bne :+
|
|
lda timer+1
|
|
bne :+
|
|
lda timer
|
|
lsr
|
|
lsr
|
|
lsr
|
|
tax
|
|
lda fade_cols, x
|
|
sta $d021
|
|
:
|
|
lda timer_mode
|
|
cmp #2
|
|
bne :+
|
|
lda timer+1
|
|
bne :+
|
|
lda timer
|
|
lsr
|
|
lsr
|
|
lsr
|
|
eor #31
|
|
tax
|
|
lda fade_cols, x
|
|
sta $d021
|
|
:
|
|
|
|
inc timer
|
|
bne :+
|
|
inc timer+1
|
|
:
|
|
lda timer
|
|
cmp timer_limit
|
|
bne :+
|
|
lda timer+1
|
|
cmp timer_limit+1
|
|
bne :+
|
|
lda #1
|
|
sta timer_reached
|
|
:
|
|
lda timer_mode
|
|
cmp #3
|
|
bne @timer_done
|
|
lda vbl
|
|
lsr a
|
|
bcs @timer_done
|
|
lsr a
|
|
and #7
|
|
ora #$38
|
|
sta $d011
|
|
|
|
@timer_done:
|
|
|
|
@dd00_arc:
|
|
lda #0
|
|
sta $dd00
|
|
|
|
pla
|
|
tay
|
|
pla
|
|
tax
|
|
pla
|
|
jmp $dc0c
|
|
|
|
|
|
fake_kernal_irq:
|
|
pha
|
|
txa
|
|
pha
|
|
tya
|
|
pha
|
|
tsx
|
|
lda $0104, x
|
|
and #$10
|
|
beq :+
|
|
jmp ($0314)
|
|
:
|
|
jmp ($0314) ; fuck you
|
|
|
|
wait_loop:
|
|
@loop2:
|
|
lda vbl
|
|
beq @loop2
|
|
|
|
lda #0
|
|
sta vbl
|
|
|
|
jsr sfx_play
|
|
|
|
dec frame_delay
|
|
lda frame_delay
|
|
beq :+
|
|
jmp @loop2
|
|
:
|
|
rts
|
|
|
|
wait_frame_until:
|
|
@loop:
|
|
lda vbl
|
|
beq @loop
|
|
|
|
lda #0
|
|
sta vbl
|
|
|
|
lda cur_frame
|
|
cmp #2
|
|
bcc :+
|
|
jsr sfx_play
|
|
:
|
|
|
|
dec bmp_delay
|
|
bpl :+
|
|
jsr update_bmp
|
|
:
|
|
|
|
lda cur_frame
|
|
cmp frame_until
|
|
beq :+
|
|
|
|
jmp @loop
|
|
:
|
|
rts
|
|
|
|
|
|
wait_loop_2x:
|
|
@loop:
|
|
lda vbl
|
|
cmp #2
|
|
bcc @loop
|
|
|
|
lda #0
|
|
sta vbl
|
|
|
|
dec frame_delay
|
|
lda frame_delay
|
|
beq :+
|
|
jmp @loop
|
|
:
|
|
rts
|
|
|
|
wait_frame_until_2x:
|
|
@loop:
|
|
lda vbl
|
|
cmp #2
|
|
bcc @loop
|
|
|
|
lda #0
|
|
sta vbl
|
|
|
|
dec bmp_delay
|
|
bpl :+
|
|
jsr update_bmp
|
|
:
|
|
|
|
lda cur_frame
|
|
cmp frame_until
|
|
beq :+
|
|
jmp @loop
|
|
:
|
|
rts
|
|
|
|
|
|
init_bmp:
|
|
lda #$0b
|
|
sta $d011
|
|
lda #$19
|
|
sta $d018
|
|
lda #$d8
|
|
sta $d016
|
|
|
|
lda $4710
|
|
lsr
|
|
lsr
|
|
lsr
|
|
lsr
|
|
sta $d020
|
|
|
|
lda $4710
|
|
and #$0f
|
|
sta $d021
|
|
|
|
lda #0
|
|
sta cur_frame
|
|
sta bmp_delay
|
|
|
|
lda #$11
|
|
sta bmp_addr
|
|
lda #$47
|
|
sta bmp_addr+1
|
|
|
|
ldx #0
|
|
:
|
|
.repeat 4, I
|
|
lda $3f40+(I*250), x
|
|
sta $400+(I*250), x
|
|
lda $4328+(I*250), x
|
|
sta $d800+(I*250), x
|
|
.endrepeat
|
|
inx
|
|
cpx #250
|
|
bne :-
|
|
|
|
lda #$3b
|
|
sta $d011
|
|
rts
|
|
|
|
inc_bmp_addr:
|
|
inc bmp_addr
|
|
bne :+
|
|
inc bmp_addr+1
|
|
:
|
|
rts
|
|
|
|
update_bmp:
|
|
ldy #0
|
|
sty scr_ptr
|
|
sty cram_ptr
|
|
lda (bmp_addr), y
|
|
jsr inc_bmp_addr
|
|
sta chr_count
|
|
cmp #0 ; tfw flags update in inc_bmp_addr
|
|
bne @skip_frame_end
|
|
lda (bmp_addr), y
|
|
jsr inc_bmp_addr
|
|
sta bmp_delay
|
|
inc cur_frame
|
|
rts
|
|
@skip_frame_end:
|
|
|
|
lda (bmp_addr), y
|
|
sta bmp_ptr
|
|
iny
|
|
lda (bmp_addr), y
|
|
clc
|
|
adc #$20
|
|
sta bmp_ptr+1
|
|
|
|
iny
|
|
lda (bmp_addr), y
|
|
sta scr_ptr_lo
|
|
iny
|
|
lda (bmp_addr), y
|
|
clc
|
|
adc #$04
|
|
sta scr_ptr+1
|
|
clc
|
|
adc #$d8-$04
|
|
sta cram_ptr+1
|
|
|
|
ldy #0
|
|
lda bmp_addr
|
|
clc
|
|
adc #4
|
|
sta bmp_addr
|
|
bcc :+
|
|
inc bmp_addr+1
|
|
:
|
|
|
|
ldx #0
|
|
@loop:
|
|
ldy #0
|
|
lda (bmp_addr), y
|
|
sta (bmp_ptr), y
|
|
iny
|
|
lda (bmp_addr), y
|
|
sta (bmp_ptr), y
|
|
iny
|
|
lda (bmp_addr), y
|
|
sta (bmp_ptr), y
|
|
iny
|
|
lda (bmp_addr), y
|
|
sta (bmp_ptr), y
|
|
iny
|
|
lda (bmp_addr), y
|
|
sta (bmp_ptr), y
|
|
iny
|
|
lda (bmp_addr), y
|
|
sta (bmp_ptr), y
|
|
iny
|
|
lda (bmp_addr), y
|
|
sta (bmp_ptr), y
|
|
iny
|
|
lda (bmp_addr), y
|
|
sta (bmp_ptr), y
|
|
|
|
lda bmp_ptr
|
|
clc
|
|
adc #8
|
|
sta bmp_ptr
|
|
bcc :+
|
|
inc bmp_ptr+1
|
|
:
|
|
|
|
ldy #8
|
|
lda (bmp_addr), y
|
|
ldy scr_ptr_lo
|
|
sta (scr_ptr), y
|
|
|
|
ldy #9
|
|
lda (bmp_addr), y
|
|
ldy scr_ptr_lo
|
|
sta (cram_ptr), y
|
|
|
|
inc scr_ptr_lo
|
|
bne :+
|
|
inc scr_ptr+1
|
|
inc cram_ptr+1
|
|
:
|
|
|
|
lda bmp_addr
|
|
clc
|
|
adc #10
|
|
sta bmp_addr
|
|
bcc :+
|
|
inc bmp_addr+1
|
|
:
|
|
|
|
dec chr_count
|
|
ldx chr_count
|
|
bne @loop
|
|
jmp update_bmp
|
|
|
|
irq_badguy:
|
|
pha
|
|
txa
|
|
pha
|
|
tya
|
|
pha
|
|
|
|
inc vbl
|
|
;inc $d020
|
|
|
|
lda #$1b
|
|
sta $d011
|
|
lda #$19
|
|
sta $d018
|
|
lda #$c8
|
|
sta $d016
|
|
lda $dd00
|
|
and #3
|
|
sta @dd00_arc+1
|
|
lda #0
|
|
sta $dd00
|
|
lda #$47
|
|
sta $d018
|
|
|
|
:
|
|
lda $d012
|
|
cmp #$fb
|
|
bcc :-
|
|
|
|
.res 2, $ea
|
|
|
|
lda #$3b
|
|
sta $d011
|
|
lda #$19
|
|
sta $d018
|
|
lda #$d8
|
|
sta $d016
|
|
@dd00_arc:
|
|
lda #0
|
|
sta $dd00
|
|
|
|
;dec $d020
|
|
|
|
asl $d019
|
|
pla
|
|
tay
|
|
pla
|
|
tax
|
|
pla
|
|
rti
|
|
|
|
badguy: .byte "badguy",0
|
|
fontname: .byte "font",0
|
|
sidname: .byte "sid", 0
|
|
introname: .byte "intrbmp", 0
|
|
towername: .byte "tower", 0
|
|
towerbeamname: .byte "towerbm", 0
|
|
fieldname: .byte "field", 0
|
|
fallingstarname: .byte "fallstar", 0
|
|
lilianame: .byte "lilia", 0
|
|
liliaheroname: .byte "lilhero", 0
|
|
islandname: .byte "island", 0
|
|
islandmapname: .byte "islandmap", 0
|
|
|
|
|
|
darmtower_txt:
|
|
.res (40-32)/2, ' '
|
|
.byte "darm's tower has fallen silent. "
|
|
.res (40-32)/2, ' '
|
|
.res (40-32)/2, ' '
|
|
.byte "what should we do? "
|
|
.res (40-32)/2, ' '
|
|
|
|
empty_txt:
|
|
.res 40, ' '
|
|
.res 40, ' '
|
|
|
|
adol_win:
|
|
.res (40-28)/2, ' '
|
|
.byte 34, "it must be adol, let's see "
|
|
.res (40-28)/2, ' '
|
|
.res (40-28)/2, ' '
|
|
.byte "how far he'll get!", 34, " "
|
|
.res (40-28)/2, ' '
|
|
|
|
too_bad_txt:
|
|
.res (40-16)/2, ' '
|
|
.byte "as you command. "
|
|
.res (40-16)/2, ' '
|
|
|
|
upload_text:
|
|
lda #$34
|
|
sta $01
|
|
|
|
stx text_ptr
|
|
sty text_ptr+1
|
|
|
|
ldy #39
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
sta $d348, y
|
|
dey
|
|
bne :-
|
|
|
|
lda #$35
|
|
sta $01
|
|
|
|
lda #1
|
|
ldy #39
|
|
:
|
|
sta $db48, y
|
|
dey
|
|
bne :-
|
|
rts
|
|
|
|
upload_text_bottom:
|
|
lda #$34
|
|
sta $01
|
|
|
|
stx text_ptr
|
|
sty text_ptr+1
|
|
|
|
ldy #39
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
sta $d348+40+40, y
|
|
dey
|
|
bne :-
|
|
|
|
lda #$35
|
|
sta $01
|
|
|
|
lda #1
|
|
ldy #39
|
|
:
|
|
sta $db48+40+40, y
|
|
dey
|
|
bne :-
|
|
rts
|
|
|
|
|
|
run_nufli_bmp:
|
|
lda #$01
|
|
sta $81
|
|
lda #$29
|
|
sta $80
|
|
lda #0
|
|
sta $d01a
|
|
jsr $a000
|
|
cli
|
|
jsr $3000
|
|
@loop:
|
|
bit $d011
|
|
bpl @loop
|
|
jsr $a003
|
|
@loop2:
|
|
bit $d011
|
|
bmi @loop2
|
|
lda #0
|
|
sta $d020
|
|
sta $d021
|
|
jsr $a003
|
|
lda $80
|
|
bne :+
|
|
dec $81
|
|
:
|
|
dec $80
|
|
lda $81
|
|
cmp #$ff
|
|
beq :+
|
|
jmp @loop
|
|
:
|
|
lda #0
|
|
sta $d015
|
|
rts
|
|
|
|
|
|
.res $ea31-*, $ff
|
|
;asl $d019
|
|
pla
|
|
tay
|
|
pla
|
|
tax
|
|
pla
|
|
rti
|
|
|
|
.res $ea81-*, $ff
|
|
;asl $d019
|
|
pla
|
|
tay
|
|
pla
|
|
tax
|
|
pla
|
|
rti
|
|
|
|
.include "sfx.asm"
|
|
.include "zx02.asm"
|
|
.include "thcmod_lz.asm"
|
|
|
|
zx02_8000:
|
|
pha
|
|
jmp :+
|
|
|
|
load_8000_zx02_2000:
|
|
lda #$20
|
|
load_8000_zx02:
|
|
pha
|
|
jsr loadraw
|
|
:
|
|
lda #0
|
|
sta ZX0_src
|
|
sta ZX0_dst
|
|
lda #$80
|
|
sta ZX0_src+1
|
|
pla
|
|
jmp zx02
|
|
|
|
clear_2bufs:
|
|
ldy #$44
|
|
.byte $2c ; skip next instruction
|
|
clear_buf:
|
|
ldy #$20
|
|
lda #$20
|
|
sta @dst+2
|
|
lda #0
|
|
tax
|
|
:
|
|
sta $400,x
|
|
sta $500,x
|
|
sta $600,x
|
|
sta $700,x
|
|
inx
|
|
bne :-
|
|
@dst:
|
|
sta $2000,x
|
|
inx
|
|
bne @dst
|
|
inc @dst+2
|
|
dey
|
|
bne @dst
|
|
rts
|
|
|
|
copybuf:
|
|
lda @bsrclo,x
|
|
sta bmp_addr
|
|
lda @bsrchi,x
|
|
sta bmp_addr+1
|
|
lda @bdstlo,x
|
|
sta bmp_ptr
|
|
lda @bdsthi,x
|
|
sta bmp_ptr+1
|
|
lda @tsrclo,x
|
|
sta text_ptr
|
|
lda @tsrchi,x
|
|
sta text_ptr+1
|
|
lda @tdstlo,x
|
|
sta scr_ptr
|
|
lda @tdsthi,x
|
|
sta scr_ptr+1
|
|
ldx #16
|
|
@loop:
|
|
ldy #23
|
|
: lda (text_ptr),y
|
|
sta (scr_ptr),y
|
|
dey
|
|
bpl :-
|
|
ldy #191
|
|
: lda (bmp_addr),y
|
|
sta (bmp_ptr),y
|
|
dey
|
|
bne :-
|
|
lda (bmp_addr),y
|
|
sta (bmp_ptr),y
|
|
; math dumb cpu be struggling a lot here
|
|
lda text_ptr
|
|
sec
|
|
sbc #40
|
|
sta text_ptr
|
|
bcs :+
|
|
dec text_ptr+1
|
|
:
|
|
lda scr_ptr
|
|
sec
|
|
sbc #40
|
|
sta scr_ptr
|
|
bcs :+
|
|
dec scr_ptr+1
|
|
:
|
|
lda bmp_addr
|
|
sec
|
|
sbc #<320
|
|
sta bmp_addr
|
|
bcs :+
|
|
dec bmp_addr+1
|
|
:
|
|
dec bmp_addr+1
|
|
lda bmp_ptr
|
|
sec
|
|
sbc #<320
|
|
sta bmp_ptr
|
|
bcs :+
|
|
dec bmp_ptr+1
|
|
:
|
|
dec bmp_ptr+1
|
|
dex
|
|
bne @loop
|
|
rts
|
|
|
|
@bsrclo: .lobytes (15+4)*320+$2040, (15+4)*320+$4040
|
|
@bsrchi: .hibytes (15+4)*320+$2040, (15+4)*320+$4040
|
|
@bdstlo: .lobytes (16+4)*320+$4040, (16+4)*320+$2040
|
|
@bdsthi: .hibytes (16+4)*320+$4040, (16+4)*320+$2040
|
|
@tsrclo: .lobytes (15+4)*40+$0408, (15+4)*40+$6008
|
|
@tsrchi: .hibytes (15+4)*40+$0408, (15+4)*40+$6008
|
|
@tdstlo: .lobytes (16+4)*40+$6008, (16+4)*40+$0408
|
|
@tdsthi: .hibytes (16+4)*40+$6008, (16+4)*40+$0408
|
|
|
|
story_writ:
|
|
.res 11, ' '
|
|
.byte "story written by"
|
|
.res 40-(16+11), ' '
|
|
.res 11, ' '
|
|
.res 5, ' '
|
|
.byte "takahiro ohura"
|
|
.res 40-(14+11+5), ' '
|
|
.res 11, ' '
|
|
.res 5, ' '
|
|
.byte "tomoo yamane"
|
|
.res 40-(12+11+5), ' '
|
|
|
|
scenario_writ:
|
|
.res (40-24)/2, ' '
|
|
.byte " scenario written by "
|
|
.res (40-24)/2, ' '
|
|
.res (40-24)/2, ' '
|
|
.byte " tomoyoshi miyazaki"
|
|
.res (40-24)/2, ' '
|
|
|
|
prog_writ:
|
|
.res (40-22)/2, ' '
|
|
.byte " programmed by "
|
|
.res (40-22)/2, ' '
|
|
.res (40-22)/2, ' '
|
|
.byte " masaya hashimoto"
|
|
.res (40-22)/2, ' '
|
|
|
|
gart_writ:
|
|
.res (40-24)/2, ' '
|
|
.byte "graphic arts designed by"
|
|
.res (40-24)/2, ' '
|
|
.res (40-24)/2, ' '
|
|
.byte " takahiro ohura "
|
|
.res (40-24)/2, ' '
|
|
.res (40-24)/2, ' '
|
|
.byte " ayano koshiro "
|
|
.res (40-24)/2, ' '
|
|
.res (40-24)/2, ' '
|
|
.byte " kazuhiko tsuzuki "
|
|
.res (40-24)/2, ' '
|
|
.res (40-24)/2, ' '
|
|
.byte " tomoo yamane "
|
|
.res (40-24)/2, ' '
|
|
|
|
music_writ:
|
|
.res (40-20)/2, ' '
|
|
.byte " music composed by "
|
|
.res (40-20)/2, ' '
|
|
.res (40-20)/2, ' '
|
|
.byte " mieko ishikawa"
|
|
.res (40-20)/2, ' '
|
|
.res (40-20)/2, ' '
|
|
.byte " yuzo koshiro "
|
|
.res (40-20)/2, ' '
|
|
.res (40-20)/2, ' '
|
|
.byte " hideya nagata "
|
|
.res (40-20)/2, ' '
|
|
|
|
scene_writ:
|
|
.res (40-22)/2, ' '
|
|
.byte "scene set by "
|
|
.res (40-22)/2, ' '
|
|
.res (40-22)/2, ' '
|
|
.byte " seigo oketani "
|
|
.res (40-22)/2, ' '
|
|
.res (40-22)/2, ' '
|
|
.byte " yoshihiko kurata"
|
|
.res (40-22)/2, ' '
|
|
|
|
clr_txt:
|
|
lda #$80
|
|
ldx #0
|
|
:
|
|
.repeat 4, I
|
|
sta $400+(I*250), x
|
|
.endrepeat
|
|
inx
|
|
cpx #250
|
|
bne :-
|
|
lda #0
|
|
ldx #0
|
|
:
|
|
.repeat 4, I
|
|
sta $d800+(I*250), x
|
|
.endrepeat
|
|
inx
|
|
cpx #250
|
|
bne :-
|
|
lda #$13
|
|
sta $d018
|
|
lda #$1b
|
|
sta $d011
|
|
rts
|
|
|
|
write_txt5:
|
|
stx text_ptr
|
|
sty text_ptr+1
|
|
|
|
ldx #0
|
|
ldy #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+8*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+10*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+12*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+14*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+16*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
rts
|
|
|
|
write_txt4:
|
|
stx text_ptr
|
|
sty text_ptr+1
|
|
|
|
ldx #0
|
|
ldy #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+9*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+11*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+13*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+15*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
rts
|
|
|
|
write_txt3:
|
|
stx text_ptr
|
|
sty text_ptr+1
|
|
|
|
ldx #0
|
|
ldy #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+10*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+12*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+14*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
rts
|
|
|
|
write_txt2:
|
|
stx text_ptr
|
|
sty text_ptr+1
|
|
|
|
ldx #0
|
|
ldy #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+11*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
|
|
ldx #0
|
|
:
|
|
lda (text_ptr), y
|
|
sec
|
|
sbc #$20
|
|
ora #$80
|
|
sta $400+13*40, x
|
|
iny
|
|
inx
|
|
cpx #40
|
|
bne :-
|
|
rts
|
|
|
|
code_end:
|