9176 lines
116 KiB
Plaintext
9176 lines
116 KiB
Plaintext
|
|
||
|
.nolist
|
||
|
#include "tse.inc"
|
||
|
.list
|
||
|
|
||
|
.org saferam1-3
|
||
|
.db $BB,$6D
|
||
|
ret
|
||
|
|
||
|
; Task block details
|
||
|
flags_base .equ 89F0h
|
||
|
flags_size .equ 60
|
||
|
sp_size .equ 2
|
||
|
task_sp .equ 0
|
||
|
task_flags .equ task_sp + sp_size
|
||
|
task_end .equ task_flags + flags_size
|
||
|
|
||
|
; Block size
|
||
|
maxblocksize .equ 100h
|
||
|
|
||
|
start:
|
||
|
jr startkrnl
|
||
|
jp verinfo ; Library function 0, Get version/functions supported
|
||
|
jp chkprog ; Library function 1, Check program
|
||
|
jp exitshell ; Library function 2, Exit from shell
|
||
|
jp taskswitch ; Library function 3, Switch task
|
||
|
jp starttask ; Library function 4, Start task
|
||
|
jp endtask ; Library function 5, End task
|
||
|
jp forceyield ; Library function 6, Force yield
|
||
|
|
||
|
verinfo
|
||
|
ld hl, %0000000001111111
|
||
|
majorver .equ 1
|
||
|
minorver .equ 6
|
||
|
ld bc, (majorver*256)+minorver
|
||
|
ret
|
||
|
|
||
|
startkrnl:
|
||
|
|
||
|
; Disable run indicator
|
||
|
bcall(_runIndicOff)
|
||
|
|
||
|
; Preserve flags
|
||
|
ld bc, flags_size
|
||
|
ld hl, flags_base
|
||
|
ld de, sysflags
|
||
|
ldir
|
||
|
|
||
|
; Set active program
|
||
|
ld hl, shellprog
|
||
|
ld de, cprogram
|
||
|
bcall(_mov9b)
|
||
|
|
||
|
; Look up the shell in the symbol table
|
||
|
ld hl, cprogram
|
||
|
rst 20h ;rMOV9TOOP1
|
||
|
call starttask
|
||
|
cp 0
|
||
|
ret nz
|
||
|
|
||
|
; Check to see if enough free RAM for block copy buffer
|
||
|
call chkEnoughForBuffer
|
||
|
|
||
|
; Preserve stack
|
||
|
ld (sysstack), sp
|
||
|
|
||
|
; Exec
|
||
|
jp taskenter
|
||
|
exitshell:
|
||
|
|
||
|
; Restore stack
|
||
|
ld hl, (sysstack)
|
||
|
ld sp, hl
|
||
|
|
||
|
; Copy out of active memory
|
||
|
call cpy_prgm_out
|
||
|
|
||
|
; End task
|
||
|
ld hl, shellprog
|
||
|
rst 20h ;rMOV9TOOP1
|
||
|
call endtask
|
||
|
|
||
|
; Clear screen
|
||
|
bcall(_clrScrnFull)
|
||
|
|
||
|
; Display exit message
|
||
|
ld hl, 0
|
||
|
ld (currow), hl
|
||
|
ld hl, msg
|
||
|
bcall(_puts)
|
||
|
|
||
|
; Disable ON flag
|
||
|
res onInterrupt, (iy+onFlags)
|
||
|
|
||
|
ret
|
||
|
|
||
|
; Force the program to yield
|
||
|
;
|
||
|
; Inputs -
|
||
|
; None
|
||
|
;
|
||
|
; Returns -
|
||
|
; Nothing
|
||
|
;
|
||
|
forceyield:
|
||
|
ld hl, shellprog
|
||
|
rst 20h ;rMOV9TOOP1
|
||
|
call taskswitch
|
||
|
ret
|
||
|
|
||
|
; Load a program into active memory and run it
|
||
|
;
|
||
|
; Inputs -
|
||
|
; OP1 should contain a program variable
|
||
|
;
|
||
|
; Returns -
|
||
|
; Nothing
|
||
|
;
|
||
|
taskswitch:
|
||
|
|
||
|
; Preserve sp
|
||
|
ld (tempword), sp
|
||
|
ld hl, (pptr_preserve)
|
||
|
push hl
|
||
|
ld de, (tempword)
|
||
|
ld (hl), e
|
||
|
inc hl
|
||
|
ld (hl), d
|
||
|
|
||
|
; Preserve var
|
||
|
ld hl, op1
|
||
|
ld de, tprogram
|
||
|
bcall(_mov9b)
|
||
|
|
||
|
; Preserve flags
|
||
|
pop hl
|
||
|
inc hl
|
||
|
inc hl
|
||
|
ex de, hl
|
||
|
ld bc, flags_size
|
||
|
ld hl, flags_base
|
||
|
ldir
|
||
|
|
||
|
; Display message
|
||
|
ld hl, 0
|
||
|
ld (currow), hl
|
||
|
set textInverse, (iy+textflags)
|
||
|
ld hl, plswait
|
||
|
bcall(_puts)
|
||
|
|
||
|
; Borrow system stack
|
||
|
ld hl, (sysstack)
|
||
|
ld sp, hl
|
||
|
|
||
|
; Check to see if enough RAM for block copy buffer
|
||
|
call chkEnoughForBuffer
|
||
|
|
||
|
; Copy current program out of memory
|
||
|
call cpy_prgm_out
|
||
|
|
||
|
; Copy program name to cprogram
|
||
|
ld hl, tprogram
|
||
|
ld de, cprogram
|
||
|
bcall(_mov9b)
|
||
|
|
||
|
taskenter:
|
||
|
|
||
|
; Check to see if enough RAM for block copy buffer
|
||
|
call chkEnoughForBuffer
|
||
|
|
||
|
; Load new program in
|
||
|
call cpy_prgm_in
|
||
|
|
||
|
; Restore flags
|
||
|
ld hl, (pptr_preserve)
|
||
|
inc hl
|
||
|
inc hl
|
||
|
ld bc, flags_size
|
||
|
ld de, flags_base
|
||
|
ldir
|
||
|
|
||
|
; Restore sp
|
||
|
ld hl, (pptr_preserve)
|
||
|
bcall(_ldHLind)
|
||
|
ld sp, hl
|
||
|
|
||
|
; Exec program
|
||
|
ret
|
||
|
|
||
|
; Remove a task block from the end of a program variable and update its
|
||
|
; status.
|
||
|
;
|
||
|
; Inputs -
|
||
|
; OP1 should contain a program variable
|
||
|
;
|
||
|
; Returns -
|
||
|
; A will equal 0 on sucess otherwise it's an error code
|
||
|
endtask:
|
||
|
|
||
|
; Find the program and set PTR_'s
|
||
|
call chkprog
|
||
|
cp 0
|
||
|
ret nz
|
||
|
|
||
|
; Check to see if task block doesn't exist
|
||
|
ld hl, (fptr_prgtitle)
|
||
|
ld a, (hl)
|
||
|
cp ' '
|
||
|
ld a, 4 ; Load error code 4 - Task block doesn't exist
|
||
|
ret z
|
||
|
|
||
|
; Calculate task block size
|
||
|
ld hl, (fptr_memreq)
|
||
|
bcall(_ldHLind)
|
||
|
ex de, hl
|
||
|
ld hl, task_end
|
||
|
add hl, de
|
||
|
push hl
|
||
|
push hl
|
||
|
|
||
|
; Find start of task block
|
||
|
ex de, hl
|
||
|
ld hl, (fptr_end)
|
||
|
or a
|
||
|
sbc hl, de
|
||
|
|
||
|
; Delete task block
|
||
|
pop de
|
||
|
bcall(_delmem)
|
||
|
|
||
|
; Update variable size field
|
||
|
ld hl, (fptr_varsize)
|
||
|
bcall(_ldHLind)
|
||
|
pop bc
|
||
|
or a
|
||
|
sbc hl, bc
|
||
|
ex de, hl
|
||
|
ld hl, (fptr_varsize)
|
||
|
ld (hl), e
|
||
|
inc hl
|
||
|
ld (hl), d
|
||
|
|
||
|
; Modify status byte and return
|
||
|
ld hl, (fptr_prgtitle)
|
||
|
ld a, ' '
|
||
|
ld (hl), a
|
||
|
|
||
|
; Success
|
||
|
xor a
|
||
|
ret
|
||
|
|
||
|
; Add a task block onto the end of a program variable and update its
|
||
|
; status.
|
||
|
;
|
||
|
; Inputs -
|
||
|
; OP1 should contain a program variable
|
||
|
;
|
||
|
; Returns -
|
||
|
; A will equal 0 on sucess otherwise it's an error code
|
||
|
starttask:
|
||
|
|
||
|
; Find the program and set PTR_'s
|
||
|
call chkprog
|
||
|
cp 0
|
||
|
ret nz
|
||
|
|
||
|
; Check to see if task block already exists
|
||
|
ld hl, (fptr_prgtitle)
|
||
|
ld a, (hl)
|
||
|
cp '*'
|
||
|
ld a, 4 ; Load error code 4 - Task block already exists
|
||
|
ret z
|
||
|
|
||
|
; Check available memory
|
||
|
ld hl, (fptr_memreq)
|
||
|
bcall(_ldHLind)
|
||
|
ld bc, task_end
|
||
|
add hl, bc
|
||
|
push hl
|
||
|
push hl
|
||
|
bcall(_enoughmem)
|
||
|
ld a, 5 ; Load error code 5 - Insufficient memory
|
||
|
ret c
|
||
|
|
||
|
; Insert memory
|
||
|
ld de, (fptr_end)
|
||
|
pop hl
|
||
|
bcall(_insertmem)
|
||
|
|
||
|
; Update variable size field
|
||
|
ld hl, (fptr_varsize)
|
||
|
bcall(_ldHLind)
|
||
|
pop bc
|
||
|
add hl, bc
|
||
|
ex de, hl
|
||
|
ld hl, (fptr_varsize)
|
||
|
ld (hl), e
|
||
|
inc hl
|
||
|
ld (hl), d
|
||
|
|
||
|
; Get address of taskblock
|
||
|
ld hl, (fptr_memreq)
|
||
|
bcall(_ldHLind)
|
||
|
ld bc, (fptr_end)
|
||
|
add hl, bc
|
||
|
push hl
|
||
|
push hl
|
||
|
push hl
|
||
|
|
||
|
; Set start address
|
||
|
ld de, userMem + 4
|
||
|
ld hl, (fptr_prgtitle)
|
||
|
findcodeaddr:
|
||
|
ld a, (hl)
|
||
|
cp 0
|
||
|
inc hl
|
||
|
inc de
|
||
|
jr nz, findcodeaddr
|
||
|
inc de
|
||
|
inc de
|
||
|
pop hl
|
||
|
dec hl
|
||
|
ld (hl), d
|
||
|
dec hl
|
||
|
ld (hl), e
|
||
|
|
||
|
; Set sp
|
||
|
ld hl, (fptr_varsize)
|
||
|
bcall(_ldHLind)
|
||
|
ld bc, userMem - (3 + task_end + 2)
|
||
|
add hl, bc
|
||
|
ex de, hl
|
||
|
pop hl
|
||
|
ld (hl), e
|
||
|
inc hl
|
||
|
ld (hl), d
|
||
|
|
||
|
; Save flags into taskblock
|
||
|
pop hl
|
||
|
inc hl
|
||
|
inc hl
|
||
|
ex de, hl
|
||
|
ld bc, flags_size
|
||
|
ld hl, sysflags
|
||
|
ldir
|
||
|
|
||
|
; Update status bytes
|
||
|
ld hl, (fptr_prgtitle)
|
||
|
ld a, '*'
|
||
|
ld (hl), a
|
||
|
|
||
|
; Success
|
||
|
xor a
|
||
|
ret
|
||
|
|
||
|
; Locate a TSE program in memory and set pointers.
|
||
|
;
|
||
|
; Inputs -
|
||
|
; OP1 should contain a program variable
|
||
|
;
|
||
|
; Returns -
|
||
|
; A will equal 0 on sucess otherwise it's an error code
|
||
|
; HL points to prgtitle
|
||
|
; (fptr_varsize), (fptr_code) and (fptr_end) set point to program
|
||
|
;
|
||
|
chkprog:
|
||
|
|
||
|
; Check to see if variable exists
|
||
|
bcall(_ChkFindSym)
|
||
|
ex de, hl
|
||
|
ld a, 1 ; Load error code 1 - Variable does not exist
|
||
|
ret c ; Return if error
|
||
|
|
||
|
; Check to see if variable is in RAM
|
||
|
ld a, b
|
||
|
cp 0
|
||
|
;OLD: ld a, 2 ; Load error code 2 - Variable is stored in FLASH-ROM
|
||
|
;OLD: ret nz ; Return if error
|
||
|
jr z, notFlash
|
||
|
ld de, saferam5
|
||
|
ld bc, 256
|
||
|
bcall(_FlashToRam)
|
||
|
ld hl, saferam5 + 9
|
||
|
ld c, (hl)
|
||
|
ld b, 0
|
||
|
inc bc
|
||
|
add hl, bc
|
||
|
call notFlash
|
||
|
cp 0
|
||
|
ret nz
|
||
|
ld a, 2 ; Load error code 2 - Variable is stored in FLASH-ROM
|
||
|
ret
|
||
|
notFlash:
|
||
|
|
||
|
; Get pointer to "variable size field"
|
||
|
ld (fptr_varsize), hl
|
||
|
|
||
|
; Get pointer to "end of variable"
|
||
|
push hl
|
||
|
bcall(_ldHLind)
|
||
|
ld de, (fptr_varsize)
|
||
|
inc de
|
||
|
inc de
|
||
|
add hl, de
|
||
|
ld (fptr_end), hl
|
||
|
pop hl
|
||
|
|
||
|
; Check that the TSE header is valid
|
||
|
ld b, 4
|
||
|
ld de, 5
|
||
|
add hl, de
|
||
|
ld de, tsevalid
|
||
|
cmpStr:
|
||
|
ld a, (de)
|
||
|
ld c, (hl)
|
||
|
cp c ; Compare strings
|
||
|
ld a, 3 ; Load error code 3 - Not a valid TSE program
|
||
|
ret nz ; Return if error
|
||
|
inc hl ; Next byte of header
|
||
|
inc de ; Next byte of tsevalid
|
||
|
djnz cmpStr
|
||
|
|
||
|
; Get pointer to "program title"
|
||
|
ld (fptr_prgtitle), hl
|
||
|
|
||
|
; Get pointer to "mem required"
|
||
|
call skipstr
|
||
|
ld (fptr_memreq), hl
|
||
|
|
||
|
; Load HL with program title
|
||
|
ld hl, (fptr_prgtitle)
|
||
|
|
||
|
; All done
|
||
|
xor a ; Load error code 0 - Sucess
|
||
|
ret
|
||
|
|
||
|
; Moves the active program into a variable
|
||
|
;
|
||
|
; Inputs -
|
||
|
; (cprogram) should contain the name of the program to load in
|
||
|
;
|
||
|
; Returns -
|
||
|
; Program is moved into variable
|
||
|
;
|
||
|
cpy_prgm_out:
|
||
|
|
||
|
; Load prgm name into OP1
|
||
|
ld hl, cprogram
|
||
|
rst 20h ;rMOV9TOOP1
|
||
|
|
||
|
; Get src
|
||
|
ld hl, userMem
|
||
|
ld (cpysrc), hl
|
||
|
|
||
|
; Clear tempword
|
||
|
ld hl, 5
|
||
|
ld (tempword), hl
|
||
|
|
||
|
; Get program size
|
||
|
ld hl, (progsize)
|
||
|
ld (bytes2go), hl
|
||
|
|
||
|
; Update size field of var
|
||
|
push hl
|
||
|
bcall(_chkfindsym)
|
||
|
ex de, hl
|
||
|
pop de
|
||
|
inc de
|
||
|
inc de
|
||
|
inc de
|
||
|
ld (hl), e
|
||
|
inc hl
|
||
|
ld (hl), d
|
||
|
|
||
|
cpyout_loop:
|
||
|
|
||
|
; Get copy block size
|
||
|
call calcblock
|
||
|
|
||
|
; Calculate cpydest
|
||
|
bcall(_chkfindsym)
|
||
|
ex de, hl
|
||
|
ld bc, (tempword)
|
||
|
add hl, bc
|
||
|
ex de, hl
|
||
|
|
||
|
; Increase size of dest
|
||
|
ld hl, (blocksize)
|
||
|
bcall(_insertmem)
|
||
|
|
||
|
; Copy data
|
||
|
ld hl, (cpysrc)
|
||
|
ld bc, (blocksize)
|
||
|
ldir
|
||
|
|
||
|
; Increase tempword
|
||
|
ld hl, (tempword)
|
||
|
ld bc, (blocksize)
|
||
|
add hl, bc
|
||
|
ld (tempword), hl
|
||
|
|
||
|
; Decrease size of src
|
||
|
ld hl, (cpysrc)
|
||
|
ld de, (blocksize)
|
||
|
bcall(_delmem)
|
||
|
|
||
|
; Loop if not finished
|
||
|
ld hl, (bytes2go)
|
||
|
xor a
|
||
|
cp h
|
||
|
jr nz, cpyout_loop
|
||
|
cp l
|
||
|
jr nz, cpyout_loop
|
||
|
|
||
|
ret
|
||
|
|
||
|
; Moves the selected variable into the active program
|
||
|
;
|
||
|
; Inputs -
|
||
|
; (cprogram) should contain the name of the program to load in
|
||
|
;
|
||
|
; Returns -
|
||
|
; Program is moved into variable
|
||
|
;
|
||
|
cpy_prgm_in:
|
||
|
|
||
|
; Load prgm name into OP1
|
||
|
ld hl, cprogram
|
||
|
rst 20h ;rMOV9TOOP1
|
||
|
|
||
|
; Get program size
|
||
|
bcall(_chkfindsym)
|
||
|
ex de, hl
|
||
|
push hl
|
||
|
bcall(_ldhlind)
|
||
|
dec hl
|
||
|
dec hl
|
||
|
dec hl
|
||
|
ld (bytes2go), hl
|
||
|
ld (progsize), hl
|
||
|
|
||
|
; Update size field of var
|
||
|
pop hl
|
||
|
ld de, 3
|
||
|
ld (hl), e
|
||
|
inc hl
|
||
|
ld (hl), d
|
||
|
|
||
|
; Get dest
|
||
|
ld hl, userMem
|
||
|
ld (cpydest), hl
|
||
|
|
||
|
cpyin_loop:
|
||
|
|
||
|
; Get copy block size
|
||
|
call calcblock
|
||
|
|
||
|
; Increase size of dest
|
||
|
ld hl, (blocksize)
|
||
|
ld de, (cpydest)
|
||
|
bcall(_insertmem)
|
||
|
|
||
|
; Calculate cpysrc
|
||
|
bcall(_chkfindsym)
|
||
|
ex de, hl
|
||
|
ld bc, 5
|
||
|
add hl, bc
|
||
|
push hl
|
||
|
|
||
|
; Copy data
|
||
|
ld bc, (blocksize)
|
||
|
ld de, (cpydest)
|
||
|
ldir
|
||
|
ld (cpydest), de
|
||
|
|
||
|
; Decrease size of src
|
||
|
pop hl
|
||
|
ld de, (blocksize)
|
||
|
bcall(_delmem)
|
||
|
|
||
|
; Loop if not finished
|
||
|
ld hl, (bytes2go)
|
||
|
xor a
|
||
|
cp h
|
||
|
jr nz, cpyin_loop
|
||
|
cp l
|
||
|
jr nz, cpyin_loop
|
||
|
|
||
|
; Set pptr_code
|
||
|
ld hl, userMem + 4
|
||
|
call skipstr
|
||
|
inc hl
|
||
|
inc hl
|
||
|
ld (pptr_code), hl
|
||
|
|
||
|
; Set pptr_preserve
|
||
|
ld hl, (progsize)
|
||
|
ld bc, userMem - task_end
|
||
|
add hl, bc
|
||
|
ld (pptr_preserve), hl
|
||
|
|
||
|
ret
|
||
|
|
||
|
; Copy block size calulating routine
|
||
|
;
|
||
|
calcblock:
|
||
|
ld bc, maxblocksize
|
||
|
smaller:
|
||
|
dec bc
|
||
|
ld hl, (bytes2go)
|
||
|
or a
|
||
|
sbc hl, bc
|
||
|
jr c, smaller
|
||
|
ld (bytes2go), hl
|
||
|
ld (blocksize), bc
|
||
|
ret
|
||
|
|
||
|
; Skip string routine
|
||
|
;
|
||
|
skipstr:
|
||
|
ld a, (hl)
|
||
|
cp 0
|
||
|
inc hl
|
||
|
jr nz, skipstr
|
||
|
ret
|
||
|
|
||
|
; Check to see if enough free RAM for block copy buffer
|
||
|
chkEnoughForBuffer:
|
||
|
ld hl, maxblocksize
|
||
|
bcall(_EnoughMem)
|
||
|
ret nc
|
||
|
pop hl ; Get return address off stack
|
||
|
ret
|
||
|
|
||
|
; Please Wait
|
||
|
;
|
||
|
plswait:
|
||
|
.db "<WAIT>",0
|
||
|
|
||
|
; Exit Message
|
||
|
;
|
||
|
msg:
|
||
|
.db "TSE v1.6",0
|
||
|
|
||
|
; The 4 byte TSE header for use by the validation code
|
||
|
;
|
||
|
tsevalid:
|
||
|
.db "TSE", 1
|
||
|
|
||
|
; Name of program to load as shell
|
||
|
;
|
||
|
shellprog:
|
||
|
.db ProtProgObj, "UTOPIA",0,0
|
||
|
|
||
|
; Memory equates
|
||
|
;
|
||
|
data:
|
||
|
|
||
|
; Memory equates (Temporary)
|
||
|
bytes2go .equ saferam2 + 400
|
||
|
blocksize .equ bytes2go + 2
|
||
|
cpysrc .equ blocksize + 2
|
||
|
cpydest .equ cpysrc + 2
|
||
|
tempword .equ cpydest + 2
|
||
|
tprogram .equ tempword + 2
|
||
|
|
||
|
.end
|
||
|
|
||
|
|
||
|
.nolist
|
||
|
#ifdef VTI
|
||
|
.echo "\nAssembling VTI version\n\n"
|
||
|
#else
|
||
|
.echo "\nAssembling Real version\n\n"
|
||
|
#endif
|
||
|
#include "csx.inc"
|
||
|
.list
|
||
|
|
||
|
#ifdef VTI
|
||
|
#define VERSION "CSX 0.27 beta - VTI"
|
||
|
#define MODEL "TI-83 Plus"
|
||
|
#define DATE "08-27-2004"
|
||
|
#define AUTHOR "Sean McLaughlin"
|
||
|
#define ORG "United-TI"
|
||
|
#define CONT1 "sigma_zk@yahoo.com"
|
||
|
#define CONT2 "www.unitedti.org"
|
||
|
#else
|
||
|
#define VERSION "CSX 0.27 beta"
|
||
|
#define MODEL "TI-83 Plus"
|
||
|
#define DATE "08-27-2004"
|
||
|
#define AUTHOR "Sean McLaughlin"
|
||
|
#define ORG "United-TI"
|
||
|
#define CONT1 "sigma_zk@yahoo.com"
|
||
|
#define CONT2 "www.unitedti.org"
|
||
|
#endif
|
||
|
|
||
|
LIBS = 54
|
||
|
|
||
|
.module _page00
|
||
|
; RST 00 - Reset
|
||
|
.org $0000
|
||
|
jp init
|
||
|
|
||
|
zp.deref_hl_alt: .export zp.deref_hl_alt
|
||
|
ld e, (hl)
|
||
|
inc hl
|
||
|
ld d, (hl)
|
||
|
inc hl
|
||
|
ret
|
||
|
|
||
|
; RST 08 - Load HL indirect
|
||
|
#if $ > $0008
|
||
|
!!!
|
||
|
.echo "OH NOES!!!111\n\n"
|
||
|
#endif
|
||
|
.org $0008
|
||
|
push af
|
||
|
ld a, (hl)
|
||
|
inc hl
|
||
|
ld h, (hl)
|
||
|
ld l, a
|
||
|
pop af
|
||
|
ret
|
||
|
|
||
|
; RST 10 - Compare HL and DE (destroys A)
|
||
|
#if $ > $0010
|
||
|
!!!
|
||
|
.echo "OH NOES!!!111\n\n"
|
||
|
#endif
|
||
|
.org $0010
|
||
|
ld a, h
|
||
|
cp d
|
||
|
ret nz
|
||
|
ld a, l
|
||
|
cp e
|
||
|
ret
|
||
|
|
||
|
zp.call_ix: .export zp.call_ix
|
||
|
jp (ix)
|
||
|
|
||
|
; RST 18 - Read keypad port
|
||
|
#if $ > $0018
|
||
|
!!!
|
||
|
.echo "OH NOES!!!111\n\n"
|
||
|
#endif
|
||
|
.org $0018
|
||
|
out (key_port), a
|
||
|
inc hl
|
||
|
dec hl
|
||
|
in a, (key_port)
|
||
|
ret
|
||
|
|
||
|
zp.call_hl .export zp.call_hl
|
||
|
jp (hl)
|
||
|
|
||
|
; RST 20 - Add accumulator to HL
|
||
|
#if $ > $0020
|
||
|
!!!
|
||
|
.echo "OH NOES!!!111\n\n"
|
||
|
#endif
|
||
|
.org $0020
|
||
|
add a, l
|
||
|
ld l, a
|
||
|
adc a, h
|
||
|
sub l
|
||
|
ld h, a
|
||
|
ret
|
||
|
|
||
|
zp.call_iy: .export zp.call_iy
|
||
|
jp (iy)
|
||
|
|
||
|
; RST 28 - Invoke user-defined SWI
|
||
|
#if $ > $0028
|
||
|
!!!
|
||
|
.echo "OH NOES!!!111\n\n"
|
||
|
#endif
|
||
|
.org $0028
|
||
|
push hl
|
||
|
ld hl, (psp.restart)
|
||
|
ex (sp), hl
|
||
|
ret
|
||
|
|
||
|
; RST 30 - Off-page call (dead weight)
|
||
|
#if $ > $0030
|
||
|
!!!
|
||
|
.echo "OH NOES!!!111\n\n"
|
||
|
#endif
|
||
|
.org $0030
|
||
|
push hl ; for ROM page
|
||
|
push hl ; for return
|
||
|
push hl
|
||
|
push de
|
||
|
push af
|
||
|
jp os_func_cont
|
||
|
|
||
|
; RST 38 - ISR
|
||
|
#if $ > $0038
|
||
|
!!!
|
||
|
.echo "OH NOES!!!111\n\n"
|
||
|
#endif
|
||
|
.org $0038
|
||
|
ex af, af'
|
||
|
exx
|
||
|
|
||
|
ld hl, os.status_flags
|
||
|
|
||
|
in a, (irq_stat_port)
|
||
|
and $08
|
||
|
jp nz, isr.on_raised
|
||
|
|
||
|
jp isr.continue
|
||
|
|
||
|
; Boot code comes here
|
||
|
#if $ > $0053
|
||
|
!!!
|
||
|
.echo "OH NOES!!!111\n\n"
|
||
|
#endif
|
||
|
.org $0053
|
||
|
jp init
|
||
|
|
||
|
; Validated OS
|
||
|
.dw $A55A
|
||
|
|
||
|
; Non-destructive compare of HL and DE
|
||
|
zp.cmp_hlde_nd: .export zp.cmp_hlde_nd
|
||
|
push hl
|
||
|
or a
|
||
|
sbc hl, de
|
||
|
pop hl
|
||
|
ret
|
||
|
|
||
|
; Non-destructive compare of HL and BC
|
||
|
zp.cmp_hlbc_nd: .export zp.cmp_hlbc_nd
|
||
|
push hl
|
||
|
or a
|
||
|
sbc hl, bc
|
||
|
pop hl
|
||
|
ret
|
||
|
|
||
|
; Version number string
|
||
|
#if $ > $0064
|
||
|
!!!
|
||
|
.echo "OH NOES!!!111\n\n"
|
||
|
#endif
|
||
|
|
||
|
os.version:
|
||
|
.db VERSION, 0
|
||
|
.db MODEL, 0
|
||
|
|
||
|
; Compare HL and BC (destroys A)
|
||
|
zp.cmp_hlbc: .export zp.cmp_hlbc
|
||
|
ld a, h
|
||
|
cp b
|
||
|
ret nz
|
||
|
ld a, l
|
||
|
cp c
|
||
|
ret
|
||
|
|
||
|
; Continuation of RST 30
|
||
|
os_func_cont:
|
||
|
ld hl, 11 ; get return address
|
||
|
add hl, sp
|
||
|
ld e, (hl)
|
||
|
dec hl
|
||
|
ld d, (hl)
|
||
|
|
||
|
in a, (flash_pageA_port) ; save the ROM page
|
||
|
dec hl
|
||
|
dec hl
|
||
|
ld (hl), a
|
||
|
|
||
|
dec hl ; set return address
|
||
|
ld (hl), os_func_exit & $FF
|
||
|
dec hl
|
||
|
ld (hl), os_func_exit >> 8
|
||
|
|
||
|
ex de, hl ; get vector address
|
||
|
ld a, (hl)
|
||
|
inc hl
|
||
|
ld h, (hl)
|
||
|
ld l, a
|
||
|
|
||
|
ld a, 1
|
||
|
out (flash_pageA_port), a
|
||
|
ld a, (hl) ; get routine page
|
||
|
inc hl
|
||
|
ld d, (hl) ; get routine address
|
||
|
inc hl
|
||
|
ld h, (hl)
|
||
|
ld l, d
|
||
|
|
||
|
out (flash_pageA_port), a ; restore inputs and transfer
|
||
|
pop af
|
||
|
pop de
|
||
|
ex (sp), hl
|
||
|
ret
|
||
|
|
||
|
os_func_exit:
|
||
|
ex (sp), hl ; restore ROM page
|
||
|
push af
|
||
|
ld a, h
|
||
|
out (flash_pageA_port), a
|
||
|
pop af
|
||
|
pop hl
|
||
|
ex (sp), hl ; advance return by 2
|
||
|
inc hl
|
||
|
inc hl
|
||
|
ex (sp), hl
|
||
|
ret
|
||
|
|
||
|
; Continuation of RST 38
|
||
|
isr.continue:
|
||
|
; ON key has been pressed
|
||
|
bit calc_on, (hl)
|
||
|
jr nz, isr.power_on
|
||
|
|
||
|
set calc_on, (hl)
|
||
|
pop af
|
||
|
|
||
|
ld hl, APS_TIME
|
||
|
ld (os.aps_timer), hl
|
||
|
|
||
|
lcd_busy
|
||
|
ld a, $03
|
||
|
out (lcd_cmd_port), a
|
||
|
lcd_busy
|
||
|
ld a, $18
|
||
|
out (lcd_cmd_port), a
|
||
|
|
||
|
isr.wait_on:
|
||
|
in a, (irq_stat_port)
|
||
|
and $08
|
||
|
jr z, isr.wait_on
|
||
|
|
||
|
isr.on_raised:
|
||
|
; Look for timer interrupt
|
||
|
in a, (irq_stat_port)
|
||
|
and $02
|
||
|
jr z, isr.timer_end
|
||
|
|
||
|
bit calc_on, (hl)
|
||
|
jr z, isr.timer_end
|
||
|
|
||
|
bit aps_on, (hl)
|
||
|
jr z, isr.timer_end
|
||
|
|
||
|
ld hl, (os.aps_timer)
|
||
|
dec hl
|
||
|
ld a, h
|
||
|
or l
|
||
|
ld (os.aps_timer), hl
|
||
|
|
||
|
call z, isr.force_off
|
||
|
|
||
|
isr.timer_end:
|
||
|
ld a, (os.status_flags)
|
||
|
and bitmask(prgm_running)
|
||
|
jr z, isr.end
|
||
|
|
||
|
ld hl, (psp.interrupt)
|
||
|
ld a, (hl)
|
||
|
cp $C7
|
||
|
inc hl
|
||
|
call z, zp.call_hl
|
||
|
|
||
|
isr.end:
|
||
|
xor a
|
||
|
out (irq_mask_port), a
|
||
|
ld a, $0B
|
||
|
out (irq_mask_port), a
|
||
|
exx
|
||
|
ex af, af'
|
||
|
ei
|
||
|
ret
|
||
|
|
||
|
isr.power_on:
|
||
|
ld a, kg_func
|
||
|
rowread
|
||
|
cp invmask(kb_2nd)
|
||
|
jr nz, isr.2nd_raised
|
||
|
|
||
|
res calc_on, (hl)
|
||
|
ld hl, isr.shut_down
|
||
|
push hl
|
||
|
jr isr.wait_on
|
||
|
|
||
|
isr.force_off:
|
||
|
ld hl, os.status_flags
|
||
|
res calc_on, (hl)
|
||
|
isr.shut_down:
|
||
|
di
|
||
|
push af
|
||
|
lcd_busy
|
||
|
ld a, $02
|
||
|
out (lcd_cmd_port), a
|
||
|
pop af
|
||
|
|
||
|
isr.off_loop:
|
||
|
push af
|
||
|
ld a, $36
|
||
|
out (irq_stat_port), a
|
||
|
ld a, $01
|
||
|
out (irq_mask_port), a
|
||
|
pop af
|
||
|
ei
|
||
|
halt
|
||
|
jr isr.off_loop
|
||
|
|
||
|
isr.2nd_raised:
|
||
|
ld hl, os.contrast
|
||
|
ld a, kg_arrows
|
||
|
rowread
|
||
|
bit kb_up, a
|
||
|
jr nz, isr.up_raised
|
||
|
|
||
|
isr.wait_up:
|
||
|
ld a, kg_arrows
|
||
|
rowread
|
||
|
bit kb_up, a
|
||
|
jr z, isr.wait_up
|
||
|
|
||
|
ld a, (hl)
|
||
|
inc a
|
||
|
jr z, isr.contrast_max
|
||
|
out (lcd_cmd_port), a
|
||
|
ld (hl), a
|
||
|
isr.contrast_max:
|
||
|
ld a, sk_up
|
||
|
ld (os.prev_key), a
|
||
|
jr isr.end
|
||
|
|
||
|
isr.up_raised:
|
||
|
bit kb_down, a
|
||
|
jr nz, isr.end
|
||
|
|
||
|
isr.wait_down:
|
||
|
ld a, kg_arrows
|
||
|
rowread
|
||
|
bit kb_down, a
|
||
|
jr z, isr.wait_down
|
||
|
|
||
|
ld a, (hl)
|
||
|
cp $C0
|
||
|
jr z, isr.contrast_min
|
||
|
dec a
|
||
|
out (lcd_cmd_port), a
|
||
|
ld (hl), a
|
||
|
isr.contrast_min:
|
||
|
ld a, sk_down
|
||
|
ld (os.prev_key), a
|
||
|
jr isr.end
|
||
|
|
||
|
|
||
|
init:
|
||
|
di
|
||
|
im 1
|
||
|
in a, (hw_port)
|
||
|
or a
|
||
|
and $80
|
||
|
jp nz, init.basic
|
||
|
|
||
|
; Silver edition
|
||
|
ld a, $81
|
||
|
out ($07), a
|
||
|
dec a
|
||
|
out ($08), a
|
||
|
xor a
|
||
|
out ($08), a
|
||
|
out ($05), a
|
||
|
out ($20), a
|
||
|
out ($30), a
|
||
|
out ($33), a
|
||
|
out ($36), a
|
||
|
ld a, $14
|
||
|
out ($29), a
|
||
|
|
||
|
init.basic:
|
||
|
; BE and SE
|
||
|
xor a
|
||
|
out (link_port), a
|
||
|
ld a, $01
|
||
|
out (irq_mask_port), a
|
||
|
ld a, $76
|
||
|
out (irq_stat_port), a
|
||
|
ld a, $41
|
||
|
out ($07), a
|
||
|
ld sp, $0000
|
||
|
|
||
|
ld hl, init.lcd_out
|
||
|
ld b, 5
|
||
|
init.lcd_loop:
|
||
|
lcd_busy
|
||
|
ld a, (hl)
|
||
|
inc hl
|
||
|
out (lcd_cmd_port), a
|
||
|
djnz init.lcd_loop
|
||
|
|
||
|
ld hl, $8000
|
||
|
ld de, $8001
|
||
|
ld bc, $8000
|
||
|
ld (hl), 0
|
||
|
ldir
|
||
|
|
||
|
ld a, $F0
|
||
|
ld (os.contrast), a
|
||
|
|
||
|
ld a, bitmask(calc_on) | bitmask(aps_on)
|
||
|
ld (os.status_flags), a
|
||
|
|
||
|
ld hl, APS_TIME
|
||
|
ld (os.aps_timer), hl
|
||
|
|
||
|
ld hl, user_ram
|
||
|
ld (os.free_mem_ptr), hl
|
||
|
|
||
|
ld hl, $0000
|
||
|
ld (os.temp_num), hl
|
||
|
|
||
|
in a, (irq_stat_port)
|
||
|
and $08
|
||
|
jr nz, $-4
|
||
|
|
||
|
call isr.force_off
|
||
|
|
||
|
call zp.cclear
|
||
|
call zp.credraw
|
||
|
call zp.vbufdisp
|
||
|
ld hl, init.str_clear
|
||
|
call zp.cputs
|
||
|
call zp.cdisp
|
||
|
jp init.all_good
|
||
|
|
||
|
init.lcd_out .db $18, $01, $F0, $40, $05
|
||
|
init.str_clear .db "Mem Cleared", 0
|
||
|
|
||
|
#include "libsrc\\string\\tokenize.z80"
|
||
|
.echo "\n"
|
||
|
|
||
|
init.all_good:
|
||
|
ei
|
||
|
zp.CONSOLE: .export zp.CONSOLE
|
||
|
ld hl, zp.CONSOLE
|
||
|
push hl
|
||
|
|
||
|
ld hl, os.arg_ptrs
|
||
|
ld de, os.arg_ptrs + 1
|
||
|
ld (hl), 0
|
||
|
ld bc, 127
|
||
|
ldir
|
||
|
|
||
|
call zp.cgets
|
||
|
|
||
|
ld hl, os.buffer
|
||
|
ld d, h
|
||
|
ld e, l
|
||
|
ld ix, os.arg_ptrs
|
||
|
call zp.tokenize
|
||
|
ld a, c
|
||
|
ld (os.arg_count), a
|
||
|
|
||
|
ld hl, (arg(0))
|
||
|
call zp.strupr
|
||
|
call zp.strlen
|
||
|
ld b, c
|
||
|
xor a
|
||
|
|
||
|
|
||
|
Hash:
|
||
|
add a, (hl)
|
||
|
inc hl
|
||
|
djnz Hash
|
||
|
and 15 ; A = HASH(x)
|
||
|
|
||
|
ld hl, hash_table
|
||
|
add a, a
|
||
|
offset_hl
|
||
|
deref_hl
|
||
|
|
||
|
ld a, (hl) ; # of strings
|
||
|
or a
|
||
|
jp z, err_syntax
|
||
|
ld b, a
|
||
|
inc hl
|
||
|
ld de, (arg(0))
|
||
|
|
||
|
Find_String:
|
||
|
call zp.strcmp
|
||
|
jr z, _Found_String
|
||
|
call zp.strnext
|
||
|
inc hl
|
||
|
inc hl
|
||
|
djnz Find_String
|
||
|
jp err_syntax
|
||
|
_Found_String:
|
||
|
call zp.strnext
|
||
|
deref_hl ; HL = address
|
||
|
ld (os.estack), sp
|
||
|
jp (hl)
|
||
|
|
||
|
|
||
|
err_syntax:
|
||
|
ld hl, str_esyntax1
|
||
|
ld de, os.scrap
|
||
|
call zp.strcpy
|
||
|
|
||
|
ld hl, os.scrap
|
||
|
ld de, (arg(0))
|
||
|
call zp.strcat
|
||
|
|
||
|
ld hl, os.scrap
|
||
|
ld de, str_esyntax2
|
||
|
call zp.strcat
|
||
|
|
||
|
ld hl, os.scrap
|
||
|
call zp.cputs
|
||
|
jp zp.cdisp
|
||
|
|
||
|
str_esyntax1 .text "Unknown: \"\000"
|
||
|
str_esyntax2 .text "\"\000"
|
||
|
|
||
|
hash_table:
|
||
|
.dw hash0, hash1, hash2, hash3, hash4, hash5, hash6, hash7
|
||
|
.dw hash8, hash9, hashA, hashB, hashC, hashD, hashE, hashF
|
||
|
|
||
|
; (byte) Commands hashing to this value
|
||
|
; (zstr) String1
|
||
|
; (word) Vector1
|
||
|
; (zstr) String2
|
||
|
; (word) Vector2
|
||
|
; etc.
|
||
|
|
||
|
hash0
|
||
|
hash1
|
||
|
hash3
|
||
|
hash4
|
||
|
hash6
|
||
|
hash7
|
||
|
hash8
|
||
|
hash9
|
||
|
hashA
|
||
|
hashB
|
||
|
hashD .db 0
|
||
|
|
||
|
hash2 .db 1
|
||
|
.db "CLS", 0
|
||
|
.dw cmd_CLS
|
||
|
|
||
|
hash5 .db 2
|
||
|
.db "HEX", 0
|
||
|
.dw cmd_HEX
|
||
|
.db "RUN", 0
|
||
|
.dw cmd_RUN
|
||
|
|
||
|
hashC .db 3
|
||
|
.db "LIST", 0
|
||
|
.dw cmd_LIST
|
||
|
.db "INFO", 0
|
||
|
.dw cmd_INFO
|
||
|
.db "KILL", 0
|
||
|
.dw cmd_KILL
|
||
|
|
||
|
hashE .db 1
|
||
|
.db "LINK", 0
|
||
|
.dw cmd_LINK
|
||
|
|
||
|
hashF .db 1
|
||
|
.db "MEM", 0
|
||
|
.dw cmd_MEM
|
||
|
|
||
|
#include "commands\\cls.z80"
|
||
|
#include "commands\\hex.z80"
|
||
|
#include "commands\\info.z80"
|
||
|
#include "commands\\kill.z80"
|
||
|
#include "commands\\link.z80"
|
||
|
#include "commands\\list.z80"
|
||
|
#include "commands\\mem.z80"
|
||
|
#include "commands\\run.z80"
|
||
|
|
||
|
gen_error:
|
||
|
ld hl, os.status_flags
|
||
|
bit prgm_running, (hl)
|
||
|
jr z, _system_error
|
||
|
ld hl, (psp.ehandler)
|
||
|
ld a, (hl)
|
||
|
cp $C7
|
||
|
jr nz, _bad_handler
|
||
|
|
||
|
inc hl
|
||
|
ld sp, (psp.stack)
|
||
|
ld a, (os.exception_num)
|
||
|
jp (hl)
|
||
|
|
||
|
_bad_handler:
|
||
|
ld hl, str_eunhandled
|
||
|
call zp.cputs
|
||
|
|
||
|
_system_error:
|
||
|
ld hl, str_exception
|
||
|
call zp.cputs
|
||
|
|
||
|
ld de, os.console + (1*24) + 2
|
||
|
ld a, (os.exception_num)
|
||
|
ld b, a
|
||
|
call zp.htoa_b
|
||
|
ld a, b
|
||
|
add a, a
|
||
|
ld hl, err_strings
|
||
|
offset_hl
|
||
|
deref_hl
|
||
|
inc de
|
||
|
call zp.strcpy
|
||
|
dec de
|
||
|
ld a, ' '
|
||
|
ld (de), a
|
||
|
|
||
|
; Dump values of AF - IY
|
||
|
ld de, os.console + (2*24) + 3
|
||
|
ld b, 6
|
||
|
_Dump_Regs:
|
||
|
pop hl
|
||
|
call zp.htoa_w
|
||
|
inc de
|
||
|
inc de
|
||
|
inc de
|
||
|
inc de
|
||
|
djnz _Dump_Regs
|
||
|
|
||
|
; Dump PC - 3
|
||
|
pop hl
|
||
|
dec hl
|
||
|
dec hl
|
||
|
dec hl
|
||
|
call zp.htoa_w
|
||
|
inc de
|
||
|
inc de
|
||
|
inc de
|
||
|
inc de
|
||
|
|
||
|
; Dump SP
|
||
|
ld hl, 0
|
||
|
add hl, sp
|
||
|
push hl
|
||
|
call zp.htoa_w
|
||
|
inc de
|
||
|
inc de
|
||
|
inc de
|
||
|
inc de
|
||
|
|
||
|
; Dump I
|
||
|
ld a, i
|
||
|
call zp.htoa_b
|
||
|
|
||
|
; Dump stack
|
||
|
pop hl
|
||
|
ld a, h
|
||
|
or l
|
||
|
jr z, _No_Stack_Dump
|
||
|
|
||
|
ld de, 30
|
||
|
add hl, de
|
||
|
ld b, 15
|
||
|
jr nc, _XXX
|
||
|
|
||
|
ld a, $1C
|
||
|
sub l
|
||
|
srl a
|
||
|
inc a
|
||
|
ld b, a
|
||
|
|
||
|
_XXX:
|
||
|
ld c, 5
|
||
|
ld de, os.console + (6*24)
|
||
|
ld hl, 0
|
||
|
add hl, sp
|
||
|
_Dump_Stack:
|
||
|
push hl
|
||
|
deref_hl
|
||
|
push bc
|
||
|
call zp.htoa_w
|
||
|
pop bc
|
||
|
|
||
|
dec c
|
||
|
jr z, _Dump_Stack1
|
||
|
inc de
|
||
|
_Dump_Stack2:
|
||
|
pop hl
|
||
|
inc hl
|
||
|
inc hl
|
||
|
djnz _Dump_Stack
|
||
|
|
||
|
|
||
|
_No_Stack_Dump:
|
||
|
call zp.cdisp
|
||
|
ld sp, (os.estack)
|
||
|
ret
|
||
|
|
||
|
_Dump_Stack1:
|
||
|
ld c, 5
|
||
|
jr _Dump_Stack2
|
||
|
|
||
|
.module HEX_EDITOR
|
||
|
_address = os.scrap
|
||
|
_cur_y = os.scrap + 2
|
||
|
_cur_x = os.scrap + 3
|
||
|
_mode = os.scrap + 4 ; 0 = hex !0 = ascii
|
||
|
_string = os.scrap + 5
|
||
|
|
||
|
app.hexedit: .export app.hexedit
|
||
|
call zp.credraw
|
||
|
|
||
|
ld hl, 0
|
||
|
ld de, (arg(1))
|
||
|
ld a, d
|
||
|
or e
|
||
|
jr z, _NoArg
|
||
|
ld b, 4
|
||
|
call zp.atoh
|
||
|
_NoArg:
|
||
|
ld (_address), hl
|
||
|
ld hl, 0
|
||
|
ld (_cur_y), hl
|
||
|
ld (_mode), hl
|
||
|
jp _Refresh
|
||
|
|
||
|
_loop:
|
||
|
ld hl, _Refresh
|
||
|
push hl
|
||
|
_inkey:
|
||
|
call zp.getch
|
||
|
|
||
|
cp k_enter
|
||
|
jp z, _Set
|
||
|
cp k_down
|
||
|
jr z, _CurDown
|
||
|
cp k_up
|
||
|
jr z, _CurUp
|
||
|
cp k_left
|
||
|
jr z, _CurLeft
|
||
|
cp k_right
|
||
|
jr z, _CurRight
|
||
|
|
||
|
range_test('C','S',_inkey,_lc)
|
||
|
or $20
|
||
|
|
||
|
_lc:
|
||
|
cp 'c'
|
||
|
jp z, _Compare
|
||
|
cp 'e'
|
||
|
jp z, _Enter
|
||
|
cp 'f'
|
||
|
jp z, _Fill
|
||
|
cp 'g'
|
||
|
jp z, _Goto
|
||
|
cp 'k'
|
||
|
jp z, _PageBack
|
||
|
cp 'l'
|
||
|
jp z, _PageAhead
|
||
|
cp 'm'
|
||
|
jp z, _Mode
|
||
|
cp 'p'
|
||
|
jp z, _Page
|
||
|
cp 's'
|
||
|
jp z, _Search
|
||
|
cp 'q'
|
||
|
jr nz, _inkey
|
||
|
|
||
|
; Exit
|
||
|
_Quit:
|
||
|
pop af
|
||
|
ret
|
||
|
|
||
|
; Move the cursor down one row
|
||
|
_CurDown:
|
||
|
call _Func_PrepCursor
|
||
|
_CurDown_2:
|
||
|
ld a, l
|
||
|
cp 7
|
||
|
jr z, _ScrollDown
|
||
|
inc l
|
||
|
_CurExit:
|
||
|
ld (_cur_y), hl
|
||
|
call _XORCursor
|
||
|
call zp.vbufdisp
|
||
|
jr _inkey
|
||
|
_ScrollDown:
|
||
|
ld de, 8
|
||
|
_CurMod:
|
||
|
ld hl, (_address)
|
||
|
add hl, de
|
||
|
ld (_address), hl
|
||
|
ret
|
||
|
|
||
|
; Move the cursor up one row
|
||
|
_CurUp:
|
||
|
call _Func_PrepCursor
|
||
|
_CurUp_2:
|
||
|
ld a, l
|
||
|
or a
|
||
|
jr z, _ScrollUp
|
||
|
dec l
|
||
|
jr _CurExit
|
||
|
_ScrollUp:
|
||
|
ld de, -8
|
||
|
jr _CurMod
|
||
|
ret
|
||
|
|
||
|
; Move the cursor left one byte
|
||
|
_CurLeft:
|
||
|
call _Func_PrepCursor
|
||
|
ld a, h
|
||
|
or a
|
||
|
jr z, _WrapLeft
|
||
|
dec h
|
||
|
jr _CurExit
|
||
|
_WrapLeft:
|
||
|
ld h, 7
|
||
|
ld (_cur_y), hl
|
||
|
jr _CurUp_2
|
||
|
|
||
|
_CurRight:
|
||
|
call _Func_PrepCursor
|
||
|
ld a, h
|
||
|
sub 7
|
||
|
jr z, _WrapRight
|
||
|
inc h
|
||
|
jr _CurExit
|
||
|
_WrapRight:
|
||
|
ld h, a
|
||
|
ld (_cur_y), hl
|
||
|
jr _CurDown_2
|
||
|
|
||
|
|
||
|
; Set a byte
|
||
|
_Set:
|
||
|
call _Func_AddressTest
|
||
|
|
||
|
ld hl, _str_set
|
||
|
call _DispCommand
|
||
|
|
||
|
ld a, (_mode)
|
||
|
or a
|
||
|
jr z, _SHex
|
||
|
ld a, (os.buffer)
|
||
|
ld d, a
|
||
|
jr _SWrite
|
||
|
|
||
|
_SHex:
|
||
|
ld de, os.buffer
|
||
|
ld b, 2
|
||
|
call zp.atoh
|
||
|
jp c, _HexError
|
||
|
ld d, l
|
||
|
|
||
|
_SWrite:
|
||
|
call _Get_Cur_Address
|
||
|
ld (hl), d
|
||
|
ret
|
||
|
|
||
|
|
||
|
_Mode:
|
||
|
ld a, (_mode)
|
||
|
cpl
|
||
|
ld (_mode), a
|
||
|
ret
|
||
|
|
||
|
|
||
|
_PageAhead:
|
||
|
ld hl, (_address)
|
||
|
ld de, 64
|
||
|
_PageAhead_2:
|
||
|
add hl, de
|
||
|
ld (_address), hl
|
||
|
ret
|
||
|
|
||
|
_PageBack:
|
||
|
ld hl, (_address)
|
||
|
ld de, -64
|
||
|
jr _PageAhead_2
|
||
|
|
||
|
|
||
|
; Warp to a specified address
|
||
|
_Goto:
|
||
|
ld hl, _str_goto
|
||
|
call _DispCommand
|
||
|
|
||
|
ld de, os.buffer
|
||
|
ld b, 4
|
||
|
call zp.atoh
|
||
|
jp c, _HexError
|
||
|
ld (_address), hl
|
||
|
ret
|
||
|
|
||
|
_Page:
|
||
|
ld hl, _str_page
|
||
|
call _DispCommand
|
||
|
|
||
|
ld de, os.buffer
|
||
|
ld b, 2
|
||
|
call zp.atoh
|
||
|
jp c, _HexError
|
||
|
ld a, l
|
||
|
out (flash_pageA_port), a
|
||
|
ret
|
||
|
|
||
|
_Compare:
|
||
|
ld hl, _str_comp
|
||
|
call _DispCommand
|
||
|
call _ParseC
|
||
|
call _Get_Cur_Address
|
||
|
ld bc, (arg(0))
|
||
|
ld de, (arg(1))
|
||
|
|
||
|
ld a, b
|
||
|
or c
|
||
|
jp z, _inkey
|
||
|
|
||
|
_CLoop:
|
||
|
ld a, (de)
|
||
|
inc de
|
||
|
cpi
|
||
|
jr nz, _CMismatch
|
||
|
jp pe, _CLoop
|
||
|
ld hl, _str_match
|
||
|
jp _HE2
|
||
|
_CMismatch:
|
||
|
dec hl
|
||
|
ld (_address), hl
|
||
|
push de
|
||
|
ld hl, _str_mismatch
|
||
|
_C2:
|
||
|
ld de, _string
|
||
|
call zp.strcpy
|
||
|
dec de
|
||
|
pop hl
|
||
|
dec hl
|
||
|
call zp.htoa_w
|
||
|
xor a
|
||
|
ld (de), a
|
||
|
sbc hl, hl
|
||
|
ld (_cur_y), hl
|
||
|
ld hl, _string
|
||
|
jp _HE2
|
||
|
|
||
|
|
||
|
_Enter:
|
||
|
call _Func_AddressTest
|
||
|
push hl
|
||
|
ld hl, _str_enter
|
||
|
call _DispCommand
|
||
|
ld de, os.buffer
|
||
|
ld a, (_mode)
|
||
|
or a
|
||
|
jr z, _EWriteH
|
||
|
|
||
|
ex de, hl
|
||
|
pop de
|
||
|
_EWriteA:
|
||
|
ld a, (hl)
|
||
|
or a
|
||
|
ret z
|
||
|
ldi
|
||
|
jr _EWriteA
|
||
|
|
||
|
|
||
|
_EWriteH:
|
||
|
pop bc
|
||
|
push bc
|
||
|
ld b, 2
|
||
|
call zp.atoh
|
||
|
pop bc
|
||
|
jp c, _HexError
|
||
|
ld a, l
|
||
|
ld (bc), a
|
||
|
inc bc
|
||
|
ld a, (de)
|
||
|
or a
|
||
|
jr nz, _EWriteH+1
|
||
|
ret
|
||
|
|
||
|
_Search:
|
||
|
ld hl, _str_search
|
||
|
call _DispCommand
|
||
|
|
||
|
ld de, os.buffer
|
||
|
ld a, (_mode)
|
||
|
or a
|
||
|
jr nz, _SAsc
|
||
|
ld ix, os.buffer
|
||
|
ld c, 0
|
||
|
_SConvHex:
|
||
|
ld b, 2
|
||
|
call zp.atoh
|
||
|
jp c, _HexError
|
||
|
ld (ix), l
|
||
|
inc ix
|
||
|
inc c
|
||
|
ld a, (de)
|
||
|
or a
|
||
|
jr nz, _SConvHex
|
||
|
jr _SDoSearch
|
||
|
|
||
|
_SAsc:
|
||
|
ld hl, os.buffer
|
||
|
call zp.strlen
|
||
|
_SDoSearch:
|
||
|
call _Get_Cur_Address
|
||
|
ld ixh, c
|
||
|
ld de, os.buffer
|
||
|
ld bc, 65535
|
||
|
_SBegin:
|
||
|
ld a, (de)
|
||
|
cpir
|
||
|
push de
|
||
|
push ix
|
||
|
_SStep:
|
||
|
inc de
|
||
|
dec ixh
|
||
|
jr z, _SFound
|
||
|
ld a, (de)
|
||
|
cpi
|
||
|
jr z, _SStep
|
||
|
_SFound:
|
||
|
pop ix
|
||
|
pop de
|
||
|
jr nz, _SBegin
|
||
|
ld d, 0
|
||
|
ld e, ixh
|
||
|
sbc hl, de
|
||
|
ld (_address), hl
|
||
|
inc hl
|
||
|
push hl
|
||
|
ld hl, _str_found
|
||
|
jp _C2
|
||
|
|
||
|
_Fill:
|
||
|
call _Func_AddressTest
|
||
|
|
||
|
ld hl, _str_fill
|
||
|
call _DispCommand
|
||
|
call _ParseFS
|
||
|
call _Get_Cur_Address
|
||
|
ld bc, (arg(0))
|
||
|
ld a, b
|
||
|
or c
|
||
|
jp z, _inkey
|
||
|
ld de, (arg(1))
|
||
|
_Fill_Loop:
|
||
|
ld (hl), e
|
||
|
inc hl
|
||
|
dec bc
|
||
|
ld a, b
|
||
|
or c
|
||
|
jr nz, _Fill_Loop
|
||
|
ret
|
||
|
|
||
|
_Get_Cur_Address:
|
||
|
ld hl, (_address)
|
||
|
ld a, (_cur_y)
|
||
|
add a, a
|
||
|
add a, a
|
||
|
add a, a
|
||
|
ld e, a
|
||
|
ld a, (_cur_x)
|
||
|
add a, e
|
||
|
offset_hl
|
||
|
ret
|
||
|
|
||
|
pop af
|
||
|
_HexError:
|
||
|
ld a, CMD_PANE
|
||
|
call zp.clrline
|
||
|
ld hl, _str_hex
|
||
|
_HE2:
|
||
|
ld bc, CMD_PANE*256+0
|
||
|
call zp.puts_con
|
||
|
ld a, CMD_PANE
|
||
|
call zp.displine
|
||
|
call zp.getch
|
||
|
ret
|
||
|
|
||
|
; Parse for FIND and SEARCH:
|
||
|
; <hex16> <hex8/ascii8>
|
||
|
_ParseFS:
|
||
|
call _Func_UnivParse
|
||
|
jr c, _HexError-1
|
||
|
ld a, (_mode)
|
||
|
or a
|
||
|
ld a, (de)
|
||
|
ld l, a
|
||
|
ld b, 2
|
||
|
call z, zp.atoh
|
||
|
jr c, _HexError-1
|
||
|
ld (arg(1)), hl
|
||
|
ret
|
||
|
|
||
|
; Parse for COMPARE:
|
||
|
; <hex16> <hex16>
|
||
|
_ParseC:
|
||
|
call _Func_UnivParse
|
||
|
jr c, _HexError-1
|
||
|
ld b, 4
|
||
|
call zp.atoh
|
||
|
jr c, _HexError-1
|
||
|
ld ((arg(1)), hl
|
||
|
ret
|
||
|
|
||
|
|
||
|
; Rebuild the display from nothing
|
||
|
_Refresh:
|
||
|
ld a, MSG_PANE
|
||
|
call zp.clrline
|
||
|
ld a, CMD_PANE
|
||
|
call zp.clrline
|
||
|
|
||
|
ld hl, (_address)
|
||
|
ld bc, 0
|
||
|
|
||
|
_Refresh_Line:
|
||
|
push bc
|
||
|
|
||
|
ld de, _string
|
||
|
call zp.htoa_w
|
||
|
ld a, ':'
|
||
|
ld (de), a
|
||
|
inc de
|
||
|
ld a, ' '
|
||
|
ld (de), a
|
||
|
inc de
|
||
|
|
||
|
call _Func_Conv
|
||
|
call _Func_Conv
|
||
|
call _Func_Conv
|
||
|
call _Func_Conv
|
||
|
|
||
|
pop bc
|
||
|
push bc
|
||
|
|
||
|
ld de, _string
|
||
|
_Refresh_Write:
|
||
|
ld a, (de)
|
||
|
inc de
|
||
|
call zp.putch_con
|
||
|
inc c
|
||
|
ld a, c
|
||
|
cp 22
|
||
|
jp nz, _Refresh_Write
|
||
|
|
||
|
pop bc
|
||
|
ld a, b
|
||
|
add a, 6
|
||
|
ld b, a
|
||
|
cp 8*6
|
||
|
jp nz, _Refresh_Line
|
||
|
|
||
|
call _XORCursor
|
||
|
call zp.vbufdisp
|
||
|
jp _loop
|
||
|
|
||
|
_XORCursor:
|
||
|
ld hl, (_cur_y)
|
||
|
ld a, h
|
||
|
ld h, 0
|
||
|
add hl, hl
|
||
|
add hl, hl
|
||
|
add hl, hl
|
||
|
ld d, h
|
||
|
ld e, l
|
||
|
add hl, hl
|
||
|
add hl, hl
|
||
|
add hl, hl
|
||
|
add hl, de
|
||
|
add a, 3
|
||
|
offset_hl
|
||
|
ld de, os.lcd_mem
|
||
|
add hl, de
|
||
|
ld b, 6
|
||
|
ld de, 12
|
||
|
_InvLoop:
|
||
|
ld a, (hl)
|
||
|
cpl
|
||
|
ld (hl), a
|
||
|
add hl, de
|
||
|
djnz _InvLoop
|
||
|
ret
|
||
|
|
||
|
_DispCommand:
|
||
|
ld a, MSG_PANE ; Display function name
|
||
|
call zp.clrline
|
||
|
ld bc, MSG_PANE*256
|
||
|
call zp.puts_con
|
||
|
ld a, MSG_PANE
|
||
|
call zp.invline
|
||
|
ld a, MSG_PANE
|
||
|
call zp.displine
|
||
|
jp zp.cgets
|
||
|
|
||
|
|
||
|
; Bunches of silly functions to shorten code size
|
||
|
|
||
|
; Code used by both parsing functions
|
||
|
_Func_UnivParse:
|
||
|
ld b, 2
|
||
|
|
||
|
ld hl, os.buffer
|
||
|
ld d, h
|
||
|
ld e, l
|
||
|
ld ix, os.arg_ptrs
|
||
|
call zp.tokenize
|
||
|
|
||
|
ld de, (arg(0))
|
||
|
ld b, 4
|
||
|
call zp.atoh
|
||
|
ret c
|
||
|
ld (arg(0)), hl
|
||
|
ld de, (arg(1))
|
||
|
ret
|
||
|
|
||
|
_Func_PrepCursor:
|
||
|
call _XORCursor ; Erase cursor highlight
|
||
|
ld hl, (_cur_y)
|
||
|
ret
|
||
|
|
||
|
; Convert bytes to ASCII or Hex
|
||
|
_Func_Conv:
|
||
|
ld a, (_mode)
|
||
|
or a
|
||
|
jr z, _Func_Conv_Hex
|
||
|
|
||
|
ld a, ' '
|
||
|
ldi
|
||
|
ld (de), a
|
||
|
inc de
|
||
|
ldi
|
||
|
ld (de), a
|
||
|
inc de
|
||
|
ret
|
||
|
|
||
|
_Func_Conv_Hex:
|
||
|
ld b, (hl)
|
||
|
inc hl
|
||
|
ld c, (hl)
|
||
|
inc hl
|
||
|
push hl
|
||
|
ld h, b
|
||
|
ld l, c
|
||
|
call zp.htoa_w
|
||
|
pop hl
|
||
|
ret
|
||
|
|
||
|
; Test if in Flash
|
||
|
_Func_AddressTest:
|
||
|
call _Get_Cur_Address
|
||
|
pop de
|
||
|
bit 7, h
|
||
|
jp z, _inkey
|
||
|
push de
|
||
|
ret
|
||
|
; "0 1 2 "
|
||
|
; "012345678901234567890123"
|
||
|
_str_comp .db "COMPARE MEMORY", 0
|
||
|
_str_enter .db "ENTER STRING", 0
|
||
|
_str_fill .db "FILL MEMORY", 0
|
||
|
_str_goto .db "GO TO ADDRESS", 0
|
||
|
_str_page .db "SET FLASH PAGE", 0
|
||
|
_str_set .db "SET BYTE", 0
|
||
|
_str_hex .db "Invalid Hex Value", 0
|
||
|
_str_match .db "Memory Matches", 0
|
||
|
_str_mismatch .db "Mismatch at ", 0
|
||
|
_str_search .db "SEARCH", 0
|
||
|
_str_found .db "String Found at ", 0
|
||
|
|
||
|
.echo "Hex Editor\t"
|
||
|
.echo $-app.hexedit
|
||
|
.echo "\n"
|
||
|
|
||
|
vect_putch_con:
|
||
|
push hl
|
||
|
push de
|
||
|
push bc
|
||
|
|
||
|
ld h, 0
|
||
|
ld l, b
|
||
|
ld d, h
|
||
|
ld e, l
|
||
|
add hl, hl
|
||
|
add hl, de
|
||
|
add hl, hl
|
||
|
add hl, hl
|
||
|
|
||
|
ld e, c
|
||
|
ld c, a ; C.0 font lsb
|
||
|
srl e
|
||
|
rl c ; C.1 font lsb C.0 = column lsb
|
||
|
add hl, de
|
||
|
|
||
|
ld de, os.lcd_mem
|
||
|
add hl, de ; HL = address into lcd_mem
|
||
|
|
||
|
push hl
|
||
|
rra
|
||
|
ld h, 0
|
||
|
ld l, a
|
||
|
ld d, h
|
||
|
ld e, l
|
||
|
add hl, hl
|
||
|
add hl, de
|
||
|
add hl, hl
|
||
|
ld de, os.font_con
|
||
|
add hl, de ; HL = address of bitmap
|
||
|
ex (sp), hl
|
||
|
pop ix ; HL -> lcd_mem IX -> bitmap
|
||
|
|
||
|
ld b, 6
|
||
|
|
||
|
_loop:
|
||
|
ld a, (ix)
|
||
|
bit 1, c
|
||
|
jr nz, _oddfont
|
||
|
rlca
|
||
|
rlca
|
||
|
rlca
|
||
|
rlca
|
||
|
_oddfont:
|
||
|
and $0F
|
||
|
ld e, $F0
|
||
|
bit 0, c
|
||
|
jr nz, _oddcolumn
|
||
|
ld e, $0F
|
||
|
rlca
|
||
|
rlca
|
||
|
rlca
|
||
|
rlca
|
||
|
_oddcolumn:
|
||
|
push af
|
||
|
ld a, (hl)
|
||
|
and e
|
||
|
ld d, a
|
||
|
pop af
|
||
|
or d
|
||
|
ld (hl), a
|
||
|
inc ix
|
||
|
ld de, 12
|
||
|
add hl, de
|
||
|
djnz _loop
|
||
|
pop bc
|
||
|
pop de
|
||
|
pop hl
|
||
|
ret
|
||
|
|
||
|
.echo "putch_con\t"
|
||
|
.echo $-vect_putch_con
|
||
|
.echo "\n"
|
||
|
|
||
|
|
||
|
vect_f_load:
|
||
|
|
||
|
_reloc_size = os.scrap
|
||
|
_load_size = os.scrap + 2
|
||
|
_reloc_ptr = os.scrap + 4
|
||
|
_load_ptr = os.scrap + 6
|
||
|
_reloc_ptr2 = os.scrap + 8
|
||
|
_reloc_endptr = os.scrap + 10
|
||
|
|
||
|
ld hl, user_ram
|
||
|
cmp_hlde
|
||
|
ret z
|
||
|
|
||
|
; Get sizes of both files
|
||
|
call zp.f_size
|
||
|
ld (_reloc_size), bc
|
||
|
ex de, hl ; HL = & load file, DE = & reloc file
|
||
|
call zp.f_size
|
||
|
ld (_load_size), bc
|
||
|
ld (_load_ptr), hl
|
||
|
ld (_reloc_ptr), de
|
||
|
|
||
|
; Compare sizes
|
||
|
ld d, b
|
||
|
ld e, c
|
||
|
ld hl, (_reloc_size) ; HL = size reloc, DE = size load
|
||
|
_CMP:
|
||
|
cmp_hlde
|
||
|
jr z, _Sizes_Are_Equal
|
||
|
jr c, _LoadFile_Is_Larger
|
||
|
|
||
|
; reloc > load
|
||
|
; Do exchange of DE bytes
|
||
|
ld b, d
|
||
|
ld c, e
|
||
|
ld hl, (_load_ptr)
|
||
|
ld de, (_reloc_ptr)
|
||
|
call zp.memswap
|
||
|
add hl, bc
|
||
|
ex de, hl
|
||
|
add hl, bc
|
||
|
ex de, hl
|
||
|
; -----------------------------------------------------
|
||
|
; | LOAD_FILE | RELOC_PT_2 | STUFF | RELOC_PT_1 | STUFF |
|
||
|
; -----------------------------------------------------
|
||
|
; ^_reloc_ptr ^DE ^_load_ptr ^HL
|
||
|
|
||
|
; Get size difference
|
||
|
ld (_reloc_ptr2), de
|
||
|
ld (_reloc_endptr), hl
|
||
|
ld hl, (_reloc_size)
|
||
|
ld de, (_load_size)
|
||
|
or a
|
||
|
sbc hl, de
|
||
|
|
||
|
; Find HL / 1024 and HL % 1024
|
||
|
ld a, h
|
||
|
and $03
|
||
|
ld b, a ; BC = HL % 1024 == HL & 0x03FF
|
||
|
ld c, l
|
||
|
or c
|
||
|
jr z, _No_Remainder
|
||
|
|
||
|
; Move HL % 1024 bytes:
|
||
|
; -------------------------------------------------------
|
||
|
; | LOAD_FILE |***RELOC_PT_2 | STUFF | RELOC_PT_1 | STUFF |
|
||
|
; -------------------------------------------------------
|
||
|
; | LOAD_FILE |<--RELOC_PT_2 | STUFF | RELOC_PT_1 | STUFF |
|
||
|
; -------------------------------------------------------
|
||
|
; | LOAD_FILE | RELOC_PT_2 | STUFF | RELOC_PT_1***| STUFF |
|
||
|
; -------------------------------------------------------
|
||
|
|
||
|
push hl
|
||
|
call _Twiddle_Bytes
|
||
|
pop hl
|
||
|
|
||
|
_No_Remainder:
|
||
|
srl h
|
||
|
srl h
|
||
|
ret z
|
||
|
ld a, h ; A = HL / 1024 == H >> 2
|
||
|
|
||
|
_Loop:
|
||
|
; Move 1024 bytes A times
|
||
|
ld bc, 1024
|
||
|
call _Twiddle_Bytes
|
||
|
dec a
|
||
|
ret z
|
||
|
jr _Loop
|
||
|
|
||
|
|
||
|
_LoadFile_Is_Larger:
|
||
|
; load > reloc
|
||
|
|
||
|
; Do exchange of HL bytes
|
||
|
ld b, h
|
||
|
ld c, l
|
||
|
push de
|
||
|
push hl
|
||
|
ld hl, (_load_ptr)
|
||
|
ld de, (_reloc_ptr)
|
||
|
call zp.memswap
|
||
|
add hl, bc
|
||
|
ex de, hl
|
||
|
add hl, bc
|
||
|
ex de, hl
|
||
|
|
||
|
; ----------------------------------------------------------------
|
||
|
; | LOAD_PT_1 | RELOC_II | RELOC_III | RELOC_I | LOAD_PT_2 | STUFF |
|
||
|
; ----------------------------------------------------------------
|
||
|
; ^_reloc_ptr ^DE ^_load_ptr ^HL
|
||
|
|
||
|
; Update vars and go through the whole rigmarole again
|
||
|
ld (_load_ptr), hl
|
||
|
ld (_reloc_ptr), de
|
||
|
ex de, hl
|
||
|
call zp.f_size
|
||
|
ld (_reloc_size), bc
|
||
|
pop de
|
||
|
pop hl
|
||
|
or a
|
||
|
sbc hl, de
|
||
|
ld (_load_size), hl
|
||
|
ex de, hl
|
||
|
ld h, b
|
||
|
ld l, c
|
||
|
jp _CMP
|
||
|
|
||
|
_Sizes_Are_Equal:
|
||
|
; Exchange DE or HL bytes
|
||
|
ld b, h
|
||
|
ld c, l
|
||
|
ld hl, (_load_ptr)
|
||
|
ld de, (_reloc_ptr)
|
||
|
jp zp.memswap
|
||
|
add hl, bc
|
||
|
ex de, hl
|
||
|
add hl, bc
|
||
|
ex de, hl
|
||
|
|
||
|
_Twiddle_Bytes:
|
||
|
ld hl, (_reloc_ptr2)
|
||
|
ld de, os.free
|
||
|
push bc
|
||
|
ldir
|
||
|
|
||
|
ex de, hl
|
||
|
ld hl, (_reloc_endptr)
|
||
|
or a
|
||
|
sbc hl, de
|
||
|
ld b, h
|
||
|
ld c, l
|
||
|
ld hl, (_reloc_ptr2)
|
||
|
ex de, hl
|
||
|
ldir
|
||
|
|
||
|
pop bc
|
||
|
ld hl, os.free
|
||
|
ldir
|
||
|
|
||
|
ret
|
||
|
|
||
|
.echo "f_load \t"
|
||
|
.echo $-vect_f_load
|
||
|
.echo "\n"
|
||
|
|
||
|
|
||
|
.module INPUT
|
||
|
vect_input:
|
||
|
push bc
|
||
|
push hl
|
||
|
|
||
|
ld b, 8 ; counter
|
||
|
ld hl, TIMEOUT ; timer
|
||
|
ld a, RED1_WHITE1
|
||
|
out (link_port), a ; Set W = 1, R = 1
|
||
|
|
||
|
_Start:
|
||
|
in a, (link_port)
|
||
|
and %00000011
|
||
|
cp %00000011
|
||
|
jr nz, _Get_Bit
|
||
|
call _Chk_Timeout
|
||
|
jr _Start
|
||
|
|
||
|
_Get_Bit:
|
||
|
cp %00000010 ; If W = 1, R = 0, a zero is incoming
|
||
|
jr z, _Receive_0
|
||
|
|
||
|
_Receive_1:
|
||
|
srl c ; Shift accumulator and set bit
|
||
|
set 7, c
|
||
|
|
||
|
ld a, RED0_WHITE1
|
||
|
out (link_port), a
|
||
|
jr _End_Wait
|
||
|
|
||
|
_Receive_0:
|
||
|
srl c
|
||
|
|
||
|
ld a, RED1_WHITE0
|
||
|
out (link_port), a
|
||
|
|
||
|
_End_Wait:
|
||
|
call _Chk_Timeout
|
||
|
in a, (link_port)
|
||
|
and %00000011
|
||
|
jr z, _End_Wait
|
||
|
ld a, RED1_WHITE1
|
||
|
out (link_port), a
|
||
|
|
||
|
ld hl, TIMEOUT
|
||
|
djnz _Start
|
||
|
|
||
|
ld a, c
|
||
|
or a
|
||
|
_Exit:
|
||
|
pop hl
|
||
|
pop bc
|
||
|
ret
|
||
|
|
||
|
_Chk_Timeout:
|
||
|
dec hl
|
||
|
ld a, h
|
||
|
or l
|
||
|
ret nz
|
||
|
_Error:
|
||
|
pop af
|
||
|
ld a, RED1_WHITE1
|
||
|
out (link_port), a
|
||
|
scf
|
||
|
jr _Exit
|
||
|
|
||
|
.echo "input \t"
|
||
|
.echo $-vect_input
|
||
|
.echo "\n"
|
||
|
|
||
|
|
||
|
_token:
|
||
|
ld a, ' '
|
||
|
cpi
|
||
|
jr z, $-2
|
||
|
dec hl
|
||
|
ld a, (hl)
|
||
|
ld bc, $2022
|
||
|
cp c
|
||
|
jr nz, $+3
|
||
|
ld b, $22
|
||
|
inc hl
|
||
|
_tok2:
|
||
|
ld a, (hl)
|
||
|
ldi
|
||
|
inc bc
|
||
|
or a
|
||
|
scf
|
||
|
ret z
|
||
|
cp b
|
||
|
jr z, _tok3
|
||
|
cp $5C
|
||
|
jr z, _escape
|
||
|
cp c
|
||
|
jr nz, _tok2
|
||
|
_tok3:
|
||
|
dec de
|
||
|
xor a
|
||
|
ld (de), a
|
||
|
inc de
|
||
|
ret
|
||
|
|
||
|
_escape:
|
||
|
ld a, (hl)
|
||
|
inc hl
|
||
|
cp $5C
|
||
|
jr z, _tok2
|
||
|
or a
|
||
|
scf
|
||
|
ret z
|
||
|
dec de
|
||
|
cp c
|
||
|
jr nz, _esc2
|
||
|
ld a, c
|
||
|
_esc3:
|
||
|
ld (de), a
|
||
|
inc de
|
||
|
jr _tok2
|
||
|
_esc2:
|
||
|
cp 'n'
|
||
|
jr nz, _tok2
|
||
|
ld a, $0A
|
||
|
jr _esc3
|
||
|
|
||
|
.echo "extract \t"
|
||
|
.echo $-vect_extract
|
||
|
.echo "\n"
|
||
|
|
||
|
.NOLIST
|
||
|
|
||
|
#define equ .equ
|
||
|
#define EQU .equ
|
||
|
#define end .end
|
||
|
|
||
|
#include "ti83plus.inc"
|
||
|
#include "mirage.inc"
|
||
|
.LIST
|
||
|
|
||
|
#DEFINE kDown 01h
|
||
|
#DEFINE kLeft 02h
|
||
|
#DEFINE kRight 03h
|
||
|
#DEFINE kUp 04h
|
||
|
#DEFINE kEnter 09h
|
||
|
#DEFINE kMode 37h
|
||
|
#DEFINE kDel 38h
|
||
|
#DEFINE kYEq 35h
|
||
|
#DEFINE k2nd 36h
|
||
|
#DEFINE kAlpha 30h
|
||
|
|
||
|
#define xmm savesscreen ; Mega Man's x-coord
|
||
|
#define ymm savesscreen+2 ; Mega Man's y-coord
|
||
|
#define jrem savesscreen+3 ; remebers the y-coord where the jump started
|
||
|
#define jchk savesscreen+4 ; check for jump: 0=no jump 1=jump up 2=jump down
|
||
|
#define wchk savesscreen+5 ; check if ok to shoot again: 0=yes >0=no
|
||
|
#define dir savesscreen+6 ; direction Mega Man is facing: 0=left 1=right
|
||
|
#define x2 savesscreen+7 ; x-coord for many different things
|
||
|
#define y2 savesscreen+8 ; y-coord for many different things
|
||
|
#define xb savesscreen+9 ; x-coord for boss
|
||
|
#define yb savesscreen+10 ; y-coord for boss
|
||
|
#define wx1 savesscreen+11 ; x-coord for 1st shot
|
||
|
#define wy1 savesscreen+12 ; y-coord for 1st shot
|
||
|
#define wx2 savesscreen+13 ; x-coord for 2nd shot
|
||
|
#define wy2 savesscreen+14 ; y-coord for 2nd shot
|
||
|
#define wx3 savesscreen+15 ; x-coord for 3rd shot
|
||
|
#define wy3 savesscreen+16 ; y-coord for 3rd shot
|
||
|
#define bdir savesscreen+17 ; direction of boss: 0=left 1=right
|
||
|
#define wdir1 savesscreen+18 ; direction of 1st shot: 0=left 1=right
|
||
|
#define wdir2 savesscreen+19 ; direction of 2nd shot: 0=left 1=right
|
||
|
#define wdir3 savesscreen+20 ; direction of 3rd shot: 0=left 1=right
|
||
|
#define wchk1 savesscreen+21 ; check if bullet #1 is still on screen: 0=no 1=yes
|
||
|
#define wchk2 savesscreen+22 ; check if bullet #2 is still on screen: 0=no 1=yes
|
||
|
#define wchk3 savesscreen+23 ; check if bullet #3 is still on screen: 0=no 1=yes
|
||
|
#define curlvl savesscreen+24 ; pointer to the beginning of the level data
|
||
|
#define feet savesscreen+26 ; check for which running sprite to use: 0 or 1
|
||
|
#define xscr savesscreen+27 ; x scroller
|
||
|
#define tempscr savesscreen+29 ; amount scrolled within incomplete block
|
||
|
#define schk savesscreen+31 ; scroll check: 0=no 1=yes
|
||
|
#define boss savesscreen+33 ; which boss u will face: 1 2 3=top row 4 5 6=middle row 7 8 9=bottom row
|
||
|
#define wpnspr savesscreen+34 ; current weapon sprite
|
||
|
#define smlspr savesscreen+36 ; current 8x8 sprite
|
||
|
#define curpic savesscreen+38 ; current pic to draw
|
||
|
#define bosspic savesscreen+40 ; current boss sprite
|
||
|
#define death savesscreen+42 ; check if dead: 0=no 1=yes
|
||
|
#define win savesscreen+44 ; check if level is completed: 0=no 1=yes
|
||
|
#define xe savesscreen+45 ; x-coord for enemy
|
||
|
#define ye savesscreen+46 ; y-coord for enemy
|
||
|
#define edir savesscreen+47 ; direction enemy is travelling
|
||
|
#define echk savesscreen+48 ; check for onscreen enemy: 0=no 1=i 2=t 3=dead
|
||
|
#define enspr savesscreen+49 ; current enemy sprite
|
||
|
#define ecount savesscreen+51 ; counts how many pixels enemy has moved (32 pixels allowed)
|
||
|
#define ecount2 savesscreen+52 ; counts how many pixels have scrolled since enemy appeared
|
||
|
#define bchk savesscreen+53 ; checks for boss: 0=no 1=yes
|
||
|
#define bwx savesscreen+54 ; x-coord of boss's shot
|
||
|
#define bwspr savesscreen+55 ; sprite for boss's shot
|
||
|
#define bwchk savesscreen+57 ; check for boss's shot onscreen
|
||
|
#define bjchk savesscreen+58 ; check for boss's jump: 0=no jump 1=jump down 2=jump up
|
||
|
#define lvldone savesscreen+59 ; checks levels completed: 0 1 2=top row 3 _ 4=middle row 5 6 7=bottom row
|
||
|
#define anpw savesscreen+60 ; checks for password dots corresponding to Anchorman
|
||
|
#define mapw savesscreen+61 ; checks for password dots corresponding to Mailman
|
||
|
#define mdpw savesscreen+62 ; checks for password dots corresponding to Madman
|
||
|
#define dopw savesscreen+63 ; checks for password dots corresponding to Doorman
|
||
|
#define popw savesscreen+64 ; checks for password dots corresponding to Policeman
|
||
|
#define frpw savesscreen+65 ; checks for password dots corresponding to Freshman
|
||
|
#define sepw savesscreen+66 ; checks for password dots corresponding to Top Secret Weapon
|
||
|
#define sapw savesscreen+67 ; checks for password dots corresponding to Salesman
|
||
|
#define mipw savesscreen+68 ; checks for password dots corresponding to Milkman
|
||
|
#define tankpw savesscreen+69 ; checks for password dots corresponding to energy tanks
|
||
|
#define lives savesscreen+70 ; the number of lives you have
|
||
|
#define tanks savesscreen+71 ; the number of energy tanks you have
|
||
|
#define remlvl savesscreen+72 ; remembers which level you were on before the special boss screens
|
||
|
#define wpn savesscreen+74 ; which weapon you are using: 1=an...5=??...9=mi
|
||
|
#define wrem1 savesscreen+75 ; remembers x-coord where short-range bullet #1 must stop
|
||
|
#define wrem2 savesscreen+76 ; remembers x-coord where short-range bullet #2 must stop
|
||
|
#define wrem3 savesscreen+77 ; remembers x-coord where short-range bullet #3 must stop
|
||
|
#define bcount savesscreen+78 ; special counting variable used for final bosses
|
||
|
#define item savesscreen+79 ; check for item in level: 0=no 1=yes 2=got
|
||
|
#define enp savesscreen+80 ; life energy
|
||
|
#define enan savesscreen+81 ; energy for anchor toss
|
||
|
#define enma savesscreen+82 ; energy for stamp throw
|
||
|
#define enmd savesscreen+83 ; energy for swearing scream
|
||
|
#define endo savesscreen+84 ; energy for splinter shot
|
||
|
#define ense savesscreen+85 ; energy for top secret weapon
|
||
|
#define enpo savesscreen+86 ; energy for badge boomerang
|
||
|
#define enfr savesscreen+87 ; energy for zit shield
|
||
|
#define ensa savesscreen+88 ; energy for bill charge
|
||
|
#define enmi savesscreen+89 ; energy for milk bubble
|
||
|
#define enwpn savesscreen+90 ; energy for current weapon
|
||
|
#define ene savesscreen+91 ; energy for enemy
|
||
|
#define enb savesscreen+92 ; energy for boss
|
||
|
#define hchk savesscreen+93 ; check if you've been hit: 0=no 1=yes
|
||
|
#define stack savesscreen+93 ; save stack for debugging (?)
|
||
|
|
||
|
.org $9d93 ;Origin (set back two to account for AsmPrgm)
|
||
|
.db $BB,$6D ;Compiled AsmPrgm token
|
||
|
ret ;So TIOS wont run the program
|
||
|
.db 1 ;Identifier as MirageOS program
|
||
|
.db %00000000,%00000000
|
||
|
.db %00000000,%00000000
|
||
|
.db %00000011,%00000000
|
||
|
.db %00000100,%10000000
|
||
|
.db %00001111,%01000000
|
||
|
.db %00001010,%11000000
|
||
|
.db %00000100,%10000000
|
||
|
.db %00000011,%00000000
|
||
|
.db %00001100,%11100000
|
||
|
.db %00001100,%11100000
|
||
|
.db %00000011,%00000000
|
||
|
.db %00000111,%11100000
|
||
|
.db %00001010,%11100000
|
||
|
.db %00001110,%00000000
|
||
|
.db %00000000,%00000000
|
||
|
Description: .db "Mega Man 83+",0
|
||
|
prog_start:
|
||
|
bcall(_grbufclr)
|
||
|
ld a,19
|
||
|
ld hl,djs
|
||
|
call centertext
|
||
|
ld a,25
|
||
|
ld hl,and_inf
|
||
|
call centertext
|
||
|
ld a,31
|
||
|
ld hl,djs2
|
||
|
call centertext
|
||
|
ld a,37
|
||
|
ld hl,pre
|
||
|
call centertext
|
||
|
djsp_loop:
|
||
|
call wait
|
||
|
call fastcopys
|
||
|
ld hl,intro
|
||
|
call draw_text
|
||
|
story_loop2:
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
xor a ; no levels completed
|
||
|
ld (lvldone),a
|
||
|
ld (tanks),a ; 0 energy tanks
|
||
|
inc a
|
||
|
ld (tankpw),a ; 0 energy tanks (for password system)
|
||
|
inc a
|
||
|
inc a
|
||
|
ld (lives),a ; 3 lives
|
||
|
ld hl,logo ; display title screen
|
||
|
ld de,PLOTSSCREEN
|
||
|
call disprle
|
||
|
call fastcopys
|
||
|
ld a,17
|
||
|
ld (x2),a
|
||
|
ld a,43
|
||
|
ld (y2),a
|
||
|
ld hl,pwdot
|
||
|
ld (smlspr),hl
|
||
|
menu_loop:
|
||
|
call xor_8x8
|
||
|
call fastcopys
|
||
|
call xor_8x8
|
||
|
bcall(_getcsc)
|
||
|
cp kUp
|
||
|
jr z,curs_change
|
||
|
cp kDown
|
||
|
jr z,curs_change
|
||
|
cp kEnter
|
||
|
jr z,title_done
|
||
|
cp kMode
|
||
|
jr nz,menu_loop
|
||
|
ret
|
||
|
curs_change:
|
||
|
ld a,(y2)
|
||
|
ld b,a
|
||
|
ld a,97
|
||
|
sub b
|
||
|
ld (y2),a
|
||
|
jr menu_loop
|
||
|
title_done:
|
||
|
ld a,(y2)
|
||
|
cp 43
|
||
|
jr z,cb_init
|
||
|
call enter_pw
|
||
|
cp kMode ; exit game if MODE was pressed on enter password screen
|
||
|
ret z
|
||
|
cb_init:
|
||
|
ld a,33
|
||
|
ld (x2),a
|
||
|
ld a,22
|
||
|
ld (y2),a
|
||
|
bcall(_clrlcdfull)
|
||
|
choose_boss:
|
||
|
bcall(_grbufclr)
|
||
|
ld hl,cbs
|
||
|
ld de,PLOTSSCREEN
|
||
|
call disprle
|
||
|
ld a,(lvldone)
|
||
|
ld c,a
|
||
|
rrc c
|
||
|
call c,no_an
|
||
|
rrc c
|
||
|
call c,no_ma
|
||
|
rrc c
|
||
|
call c,no_md
|
||
|
rrc c
|
||
|
call c,no_do
|
||
|
rrc c
|
||
|
call c,no_po
|
||
|
rrc c
|
||
|
call c,no_fr
|
||
|
rrc c
|
||
|
call c,no_sa
|
||
|
rrc c
|
||
|
call c,no_mi
|
||
|
call fastcopys
|
||
|
boss_loop:
|
||
|
call xor_corners
|
||
|
call fastcopys
|
||
|
call xor_corners
|
||
|
bcall(_getcsc)
|
||
|
cp kUp
|
||
|
jr z,bcurs_up
|
||
|
cp kDown
|
||
|
jr z,bcurs_down
|
||
|
cp kLeft
|
||
|
jr z,bcurs_left
|
||
|
cp kRight
|
||
|
jr z,bcurs_right
|
||
|
cp kEnter
|
||
|
jr z,find_boss
|
||
|
cp kMode
|
||
|
jr nz,boss_loop
|
||
|
bcall(_getcsc) ; clear the keybuffer
|
||
|
bcall(_grbufclr)
|
||
|
bcall(_clrlcdfull)
|
||
|
ret
|
||
|
bcurs_up:
|
||
|
ld a,(y2)
|
||
|
cp 1
|
||
|
jr z,boss_loop
|
||
|
ld a,(y2)
|
||
|
sub 21
|
||
|
ld (y2),a
|
||
|
jr boss_loop
|
||
|
bcurs_down:
|
||
|
ld a,(y2)
|
||
|
cp 43
|
||
|
jp z,boss_loop
|
||
|
ld a,(y2)
|
||
|
add a,21
|
||
|
ld (y2),a
|
||
|
jp boss_loop
|
||
|
bcurs_left:
|
||
|
ld a,(x2)
|
||
|
cp 2
|
||
|
jp z,boss_loop
|
||
|
ld a,(x2)
|
||
|
sub 31
|
||
|
ld (x2),a
|
||
|
jp boss_loop
|
||
|
bcurs_right:
|
||
|
ld a,(x2)
|
||
|
cp 64
|
||
|
jp z,boss_loop
|
||
|
ld a,(x2)
|
||
|
add a,31
|
||
|
ld (x2),a
|
||
|
jp boss_loop
|
||
|
find_boss:
|
||
|
ld a,(y2)
|
||
|
cp 1
|
||
|
jr z,row1
|
||
|
cp 22
|
||
|
jr z,row2
|
||
|
ld a,7
|
||
|
jr found_row
|
||
|
row2:
|
||
|
ld a,4
|
||
|
jr found_row
|
||
|
row1:
|
||
|
ld a,1
|
||
|
found_row:
|
||
|
ld (boss),a
|
||
|
ld a,(x2)
|
||
|
cp 64
|
||
|
jr z,add2
|
||
|
cp 33
|
||
|
jr nz,add0
|
||
|
ld a,(boss)
|
||
|
inc a
|
||
|
jr add_done
|
||
|
add0:
|
||
|
ld a,(boss)
|
||
|
jr add_done
|
||
|
add2:
|
||
|
ld a,(boss)
|
||
|
add a,2
|
||
|
add_done:
|
||
|
ld (boss),a
|
||
|
ld a,44
|
||
|
ld (xb),a
|
||
|
ld a,27
|
||
|
ld (yb),a
|
||
|
ld a,(boss)
|
||
|
cp 1
|
||
|
jr z,an_init
|
||
|
cp 2
|
||
|
jr z,ma_init
|
||
|
cp 3
|
||
|
jr z,md_init
|
||
|
cp 4
|
||
|
jp z,do_init
|
||
|
cp 5
|
||
|
jp z,ti_init
|
||
|
cp 6
|
||
|
jp z,po_init
|
||
|
cp 7
|
||
|
jp z,fr_init
|
||
|
cp 8
|
||
|
jp z,sa_init
|
||
|
cp 9
|
||
|
jp z,mi_init
|
||
|
an_init:
|
||
|
ld a,(lvldone)
|
||
|
bit 0,a
|
||
|
jp c,choose_boss
|
||
|
ld hl,ansl
|
||
|
call disp_boss
|
||
|
ld hl,wpan
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,a_n
|
||
|
call centertext
|
||
|
ld hl,lvlan
|
||
|
jp intro_done
|
||
|
ma_init:
|
||
|
ld a,(lvldone)
|
||
|
bit 1,a
|
||
|
jp nz,choose_boss
|
||
|
ld hl,masl
|
||
|
call disp_boss
|
||
|
ld hl,wpma
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,m_a
|
||
|
call centertext
|
||
|
ld hl,lvlma
|
||
|
jp intro_done
|
||
|
md_init:
|
||
|
ld a,(lvldone)
|
||
|
bit 2,a
|
||
|
jp nz,choose_boss
|
||
|
ld hl,mdsl
|
||
|
call disp_boss
|
||
|
ld hl,wpmd
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,m_d
|
||
|
call centertext
|
||
|
ld hl,lvlmd
|
||
|
jp intro_done
|
||
|
do_init:
|
||
|
ld a,(lvldone)
|
||
|
bit 3,a
|
||
|
jp nz,choose_boss
|
||
|
ld hl,dosl
|
||
|
call disp_boss
|
||
|
ld hl,wpdo
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,d_o
|
||
|
call centertext
|
||
|
ld hl,lvldo
|
||
|
jp intro_done
|
||
|
ti_init:
|
||
|
ld a,(lvldone)
|
||
|
rrc a
|
||
|
jp nc,choose_boss
|
||
|
rrc a
|
||
|
jp nc,choose_boss
|
||
|
rrc a
|
||
|
jp nc,choose_boss
|
||
|
rrc a
|
||
|
jp nc,choose_boss
|
||
|
rrc a
|
||
|
jp nc,choose_boss
|
||
|
rrc a
|
||
|
jp nc,choose_boss
|
||
|
rrc a
|
||
|
jp nc,choose_boss
|
||
|
rrc a
|
||
|
jp nc,choose_boss
|
||
|
ld hl,tisl
|
||
|
call disp_boss
|
||
|
ld hl,wpp
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,t_i
|
||
|
call centertext
|
||
|
ld hl,lvlti
|
||
|
jp intro_done
|
||
|
po_init:
|
||
|
ld a,(lvldone)
|
||
|
bit 4,a
|
||
|
jp nz,choose_boss
|
||
|
ld hl,posl
|
||
|
call disp_boss
|
||
|
ld hl,wppo
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,p_o
|
||
|
call centertext
|
||
|
ld hl,lvlpo
|
||
|
jr intro_done
|
||
|
fr_init:
|
||
|
ld a,(lvldone)
|
||
|
bit 5,a
|
||
|
jp nz,choose_boss
|
||
|
ld hl,frsl
|
||
|
call disp_boss
|
||
|
ld hl,wpfr
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,f_r
|
||
|
call centertext
|
||
|
ld hl,lvlfr
|
||
|
jr intro_done
|
||
|
sa_init:
|
||
|
ld a,(lvldone)
|
||
|
bit 6,a
|
||
|
jp nz,choose_boss
|
||
|
ld hl,sasl
|
||
|
call disp_boss
|
||
|
ld hl,wpsa
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,s_a
|
||
|
call centertext
|
||
|
ld hl,lvlsa
|
||
|
jr intro_done
|
||
|
mi_init:
|
||
|
ld a,(lvldone)
|
||
|
bit 7,a
|
||
|
jp nz,choose_boss
|
||
|
ld hl,misl
|
||
|
call disp_boss
|
||
|
ld hl,wpmi
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,m_i
|
||
|
call centertext
|
||
|
ld hl,lvlmi
|
||
|
intro_done:
|
||
|
ld (curlvl),hl ; remember the start of the level
|
||
|
ld (remlvl),hl
|
||
|
call delay
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
call wpn_fill
|
||
|
part1_init:
|
||
|
call init_vars
|
||
|
ld a,44 ; initialize some variables
|
||
|
ld (ymm),a
|
||
|
xor a
|
||
|
ld (jchk),a
|
||
|
ld (bchk),a
|
||
|
ld (wpn),a
|
||
|
inc a
|
||
|
ld (dir),a
|
||
|
ld (schk),a
|
||
|
ld hl,wpp
|
||
|
ld (wpnspr),hl
|
||
|
call ShowLevel
|
||
|
call main_loop
|
||
|
bcall(_getcsc) ; clear the keybuffer
|
||
|
bcall(_grbufclr)
|
||
|
bcall(_clrlcdfull)
|
||
|
ld a,(death) ; check if died
|
||
|
or a
|
||
|
jp nz,lost_life
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
ret z ; exit loop if level has not been completed
|
||
|
part2_init:
|
||
|
ld hl,lvlb1
|
||
|
xor a
|
||
|
ld (bchk),a
|
||
|
call init_lvlb
|
||
|
ld a,(death) ; check if died
|
||
|
or a
|
||
|
jp nz,lost_life
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
ret z ; exit loop if level has not been completed
|
||
|
xor a ; initialize boss variables
|
||
|
ld (bdir),a
|
||
|
ld (bjchk),a
|
||
|
inc a
|
||
|
ld (bchk),a
|
||
|
ld a,28
|
||
|
ld (enb),a
|
||
|
ld a,44
|
||
|
ld (yb),a
|
||
|
ld a,76
|
||
|
ld (xb),a
|
||
|
ld hl,lvlb2
|
||
|
call init_lvlb
|
||
|
ld a,(death) ; check if died
|
||
|
or a
|
||
|
jp nz,lost_life
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
ret z ; exit game if level has not been completed
|
||
|
ld a,(lvldone)
|
||
|
ld b,a
|
||
|
ld a,(boss)
|
||
|
cp 5
|
||
|
jp z,final_boss
|
||
|
cp 1
|
||
|
jr z,set_bit0
|
||
|
cp 2
|
||
|
jr z,set_bit1
|
||
|
cp 3
|
||
|
jr z,set_bit2
|
||
|
cp 4
|
||
|
jr z,set_bit3
|
||
|
cp 6
|
||
|
jr z,set_bit4
|
||
|
cp 7
|
||
|
jr z,set_bit5
|
||
|
cp 8
|
||
|
jr z,set_bit6
|
||
|
set 7,b
|
||
|
jr set_bit_done
|
||
|
set_bit6:
|
||
|
set 6,b
|
||
|
jr set_bit_done
|
||
|
set_bit5:
|
||
|
set 5,b
|
||
|
jr set_bit_done
|
||
|
set_bit4:
|
||
|
set 4,b
|
||
|
jr set_bit_done
|
||
|
set_bit3:
|
||
|
set 3,b
|
||
|
jr set_bit_done
|
||
|
set_bit2:
|
||
|
set 2,b
|
||
|
jr set_bit_done
|
||
|
set_bit1:
|
||
|
set 1,b
|
||
|
jr set_bit_done
|
||
|
set_bit0:
|
||
|
set 0,b
|
||
|
set_bit_done:
|
||
|
ld a,b
|
||
|
ld (lvldone),a
|
||
|
call you_got ; show "you got x weapon" screen
|
||
|
cp kMode ; exit is MODE was pressed at you got screen
|
||
|
ret z
|
||
|
call show_pw ; show password
|
||
|
cp kMode ; exit if MODE was pressed at show password screen
|
||
|
ret z
|
||
|
jp cb_init
|
||
|
lost_life:
|
||
|
call wpn_fill
|
||
|
ld a,(lives) ; go to game over screen if all lives lost
|
||
|
or a
|
||
|
jr z,game_over
|
||
|
ld a,(schk)
|
||
|
or a
|
||
|
jp z,part2_init
|
||
|
jp part1_init
|
||
|
game_over:
|
||
|
call show_pw
|
||
|
cp kMode ; exit if MODE was pressed at show password screen
|
||
|
ret z
|
||
|
ld a,3
|
||
|
ld (lives),a
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
ld hl,game_over_lindat
|
||
|
call draw
|
||
|
call fastcopys
|
||
|
ld de,18*256+31
|
||
|
ld hl,gover
|
||
|
call setvputs
|
||
|
ld de,25*256+25
|
||
|
ld hl,cont
|
||
|
call setvputs
|
||
|
ld de,32*256+14
|
||
|
ld hl,stgsel
|
||
|
call setvputs
|
||
|
ld de,39*256+31
|
||
|
ld hl,endgame
|
||
|
call setvputs
|
||
|
bcall(_grbufclr)
|
||
|
go_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp k2nd
|
||
|
jr z,go_cont
|
||
|
cp kAlpha
|
||
|
jp z,cb_init
|
||
|
cp kMode
|
||
|
ret z
|
||
|
jr go_loop
|
||
|
go_cont:
|
||
|
ld hl,(remlvl)
|
||
|
ld (curlvl),hl
|
||
|
jp part1_init
|
||
|
final_boss:
|
||
|
xor a
|
||
|
ld (boss),a ;select boss 0
|
||
|
ld (win),a ;you haven't won
|
||
|
call main_loop ;call the main loop
|
||
|
ld a,(death) ;check if you died
|
||
|
or a
|
||
|
jp nz,lost_life
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
ret z ; exit game if level has not been completed
|
||
|
ending:
|
||
|
ld hl,endingtext
|
||
|
call draw_text
|
||
|
ld hl,creditext
|
||
|
call draw_text
|
||
|
ld a,11
|
||
|
ld hl,pres
|
||
|
call centertext
|
||
|
ld a,22
|
||
|
ld hl,djs
|
||
|
call centertext
|
||
|
ld a,28
|
||
|
ld hl,and_inf
|
||
|
call centertext
|
||
|
ld a,34
|
||
|
ld hl,djs2
|
||
|
call centertext
|
||
|
call clrwait
|
||
|
ret
|
||
|
init_lvlb:
|
||
|
ld (curlvl),hl
|
||
|
call init_vars
|
||
|
ld (schk),a
|
||
|
ld (bcount),a
|
||
|
call ShowLevel
|
||
|
call main_loop
|
||
|
ld a,(win) ; see if you defeated TI's spaceship
|
||
|
cp 2
|
||
|
jr z,ship_dead
|
||
|
bcall(_getcsc) ; clear the keybuffer
|
||
|
bcall(_grbufclr)
|
||
|
bcall(_clrlcdfull)
|
||
|
ret
|
||
|
init_vars:
|
||
|
ld hl,0
|
||
|
ld (xscr),hl
|
||
|
ld (tempscr),hl
|
||
|
ld hl,8 ; initialize some variables
|
||
|
ld (xmm),hl
|
||
|
xor a
|
||
|
ld (wchk),a
|
||
|
ld (wchk1),a
|
||
|
ld (wchk2),a
|
||
|
ld (wchk3),a
|
||
|
ld (win),a
|
||
|
ld (death),a
|
||
|
ld (feet),a
|
||
|
ld (item),a
|
||
|
ld (echk),a
|
||
|
ld (bwchk),a
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
ship_dead:
|
||
|
ld a,28
|
||
|
ld (enb),a
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ld b,0 ; erase ship
|
||
|
call ship_init
|
||
|
ti_fall: ; TI falls to the bottom of the screen
|
||
|
ld a,(yb)
|
||
|
inc a
|
||
|
ld (yb),a
|
||
|
call xor_boss
|
||
|
call fastcopys
|
||
|
call xor_boss
|
||
|
ld a,(yb)
|
||
|
cp 44
|
||
|
jr nz,ti_fall
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ret
|
||
|
main_loop:
|
||
|
ld a,(hchk)
|
||
|
or a
|
||
|
call nz,thrown_back
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld a,(ymm)
|
||
|
add a,4
|
||
|
push hl
|
||
|
push af
|
||
|
call GetBlock
|
||
|
call CheckItem
|
||
|
pop af
|
||
|
pop hl
|
||
|
ld de,7
|
||
|
add hl,de
|
||
|
call GetBlock
|
||
|
call CheckItem
|
||
|
ld a,(echk)
|
||
|
or a
|
||
|
call nz,check_ehitu
|
||
|
ld a,(bchk)
|
||
|
or a
|
||
|
call nz,check_bhitu
|
||
|
ld a,(bwchk)
|
||
|
or a
|
||
|
call nz,check_bwhitu
|
||
|
call ShowLevel
|
||
|
ld a,(boss) ;draw spaceship if necessary
|
||
|
cp 5
|
||
|
ld b,1
|
||
|
call z,ship_init ;if at boss 5 (TI) draw the ship
|
||
|
call draw_nrg ; draw energy lines
|
||
|
call check_spr ; figure out which Mega Man sprite to use
|
||
|
call xor_char ; draw it
|
||
|
ld a,(wchk1) ; check if shots should be displayed and display as necessary
|
||
|
or a
|
||
|
call nz,xor_wpn1
|
||
|
ld a,(wchk2)
|
||
|
or a
|
||
|
call nz,xor_wpn2
|
||
|
ld a,(wchk3)
|
||
|
or a
|
||
|
call nz,xor_wpn3
|
||
|
ld a,(echk) ;check for enemy and display as necessary
|
||
|
push af
|
||
|
cp 1
|
||
|
call z,xor_en
|
||
|
pop af
|
||
|
cp 2
|
||
|
call z,xor_en
|
||
|
ld a,(bwchk) ;check for boss's shot and display as necessary
|
||
|
or a
|
||
|
call nz,xor_bwpn
|
||
|
ld a,(bchk) ;check for boss and display as necessary
|
||
|
or a
|
||
|
call nz,xor_boss
|
||
|
call fastcopys ;copy everything to the buffer
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
call z,die
|
||
|
call xor_char ;erase the Megaman sprite
|
||
|
ld a,(wchk1) ;check for shots and erase as necessary
|
||
|
or a
|
||
|
call nz,shot1_move
|
||
|
ld a,(wchk2)
|
||
|
or a
|
||
|
call nz,shot2_move
|
||
|
ld a,(wchk3)
|
||
|
or a
|
||
|
call nz,shot3_move
|
||
|
ld a,(echk) ;check for enemy and erase as necessary
|
||
|
push af
|
||
|
cp 1
|
||
|
call z,i_move
|
||
|
pop af
|
||
|
cp 2
|
||
|
call z,t_move
|
||
|
ld a,(bwchk) ;check for boss's shot and erase as necessary
|
||
|
or a
|
||
|
call nz,boss_shot_move
|
||
|
ld a,(bchk) ;check for boss and erase as necessary
|
||
|
or a
|
||
|
call nz,boss_move
|
||
|
bcall(_grbufclr)
|
||
|
ld a,(wchk)
|
||
|
or a
|
||
|
call nz,inc_wchk
|
||
|
call find_spr
|
||
|
ld a,$FD ;check ENTER
|
||
|
out (1),a
|
||
|
in a,(1)
|
||
|
bit 0,a
|
||
|
call z,pause
|
||
|
ld a,$FE ;check arrow keys
|
||
|
out (1),a
|
||
|
in a,(1)
|
||
|
bit 1,a
|
||
|
call z,move_left
|
||
|
bit 2,a
|
||
|
call z,move_right
|
||
|
ld a,$BF ;check other keys
|
||
|
out (1),a
|
||
|
in a,(1)
|
||
|
bit 4,a
|
||
|
call z,sub_screen
|
||
|
bit 5,a
|
||
|
push af
|
||
|
call z,jump
|
||
|
call nz,jchk_now_2
|
||
|
call fall
|
||
|
pop af
|
||
|
bit 6,a
|
||
|
ret z ;exit loop is MODE has been pressed
|
||
|
ld a,$DF ;check ALPHA
|
||
|
out (1),a
|
||
|
in a,(1)
|
||
|
bit 7,a
|
||
|
call z,shoot
|
||
|
ld a,(death)
|
||
|
or a
|
||
|
ret nz ;exit loop if dead
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
jp z,main_loop ;exit loop if level completed
|
||
|
ret
|
||
|
pause:
|
||
|
call tiny_delay
|
||
|
pause_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp kMode
|
||
|
ret z
|
||
|
cp kEnter
|
||
|
jr nz,pause_loop
|
||
|
call tiny_delay
|
||
|
ret
|
||
|
jchk_now_2: ; make sure you can't jump
|
||
|
push af
|
||
|
ld a,2
|
||
|
ld (jchk),a
|
||
|
pop af
|
||
|
ret
|
||
|
move_right:
|
||
|
ld a,(feet)
|
||
|
and $02
|
||
|
ld hl,mmrr2
|
||
|
jr nz,rr2_spr
|
||
|
ld hl,mmrr
|
||
|
rr2_spr:
|
||
|
ld (curpic),hl
|
||
|
ld a,(xmm)
|
||
|
cp 80
|
||
|
call z,won
|
||
|
call CheckRight
|
||
|
call z,CheckRight2
|
||
|
call z,CheckRight3
|
||
|
jr nz,no_right
|
||
|
call change_right
|
||
|
ld a,(xmm)
|
||
|
cp 44
|
||
|
jr nz,no_scroll
|
||
|
ld a,(xscr)
|
||
|
cp 68
|
||
|
jr z,no_scroll
|
||
|
ld a,(schk)
|
||
|
or a
|
||
|
jr z,no_scroll
|
||
|
call scroll
|
||
|
jr no_right
|
||
|
no_scroll:
|
||
|
ld hl,(xmm)
|
||
|
inc hl
|
||
|
ld (xmm),hl
|
||
|
no_right:
|
||
|
ld a,(dir)
|
||
|
or a
|
||
|
call z,change_right
|
||
|
ret
|
||
|
change_right:
|
||
|
call feet_inc
|
||
|
ld a,1
|
||
|
ld (dir),a
|
||
|
ret
|
||
|
move_left:
|
||
|
push af
|
||
|
ld a,(feet)
|
||
|
and $02
|
||
|
ld hl,mmrl2
|
||
|
jr nz,rl2_spr
|
||
|
ld hl,mmrl
|
||
|
rl2_spr:
|
||
|
ld (curpic),hl
|
||
|
ld a,(xmm)
|
||
|
or a
|
||
|
jr z,no_left
|
||
|
call CheckLeft
|
||
|
call z,CheckLeft2
|
||
|
call z,CheckLeft3
|
||
|
jr nz,no_left
|
||
|
call change_left
|
||
|
ld hl,(xmm)
|
||
|
dec hl
|
||
|
ld (xmm),hl
|
||
|
no_left:
|
||
|
ld a,(dir)
|
||
|
or a
|
||
|
call nz,change_left
|
||
|
pop af
|
||
|
ret
|
||
|
change_left:
|
||
|
call feet_inc
|
||
|
xor a
|
||
|
ld (dir),a
|
||
|
ret
|
||
|
CheckRight:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld de,8
|
||
|
add hl,de
|
||
|
jr CheckHorz
|
||
|
CheckLeft:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
dec hl
|
||
|
CheckHorz:
|
||
|
ld a,(ymm)
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
CheckRight2:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld de,8
|
||
|
add hl,de
|
||
|
jr CheckHorz2
|
||
|
CheckLeft2:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
dec hl
|
||
|
CheckHorz2:
|
||
|
ld a,(ymm)
|
||
|
add a,11
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
CheckRight3:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld de,8
|
||
|
add hl,de
|
||
|
jr CheckHorz3
|
||
|
CheckLeft3:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
dec hl
|
||
|
CheckHorz3:
|
||
|
ld a,(ymm)
|
||
|
add a,6
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
GetBlock: ; Gets the block at (HL,A) -> A. HL = addr, B,C = coord
|
||
|
srl h
|
||
|
rr l
|
||
|
srl h
|
||
|
rr l
|
||
|
srl h
|
||
|
rr l ; Divide X with 8
|
||
|
ld b,l
|
||
|
cp 64
|
||
|
jr c,OnScreen
|
||
|
xor a
|
||
|
OnScreen:
|
||
|
srl a
|
||
|
srl a
|
||
|
srl a ; Divide Y with 8
|
||
|
ld c,a
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
ld d,0
|
||
|
ld e,a
|
||
|
add hl,de ; HL = x*8+y
|
||
|
ld de,(curlvl)
|
||
|
add hl,de ; Add HL with the pointer to the level data
|
||
|
ld a,(hl)
|
||
|
ret
|
||
|
CheckTile:
|
||
|
or a
|
||
|
ret z
|
||
|
cp 5
|
||
|
ret c
|
||
|
xor a
|
||
|
ret
|
||
|
CheckItem:
|
||
|
cp 5
|
||
|
jr z,got_life
|
||
|
cp 6
|
||
|
jr z,got_tank
|
||
|
ret
|
||
|
got_life:
|
||
|
ld a,(item)
|
||
|
cp 1
|
||
|
ret nz
|
||
|
inc a
|
||
|
ld (item),a
|
||
|
ld a,(lives)
|
||
|
inc a
|
||
|
ld (lives),a
|
||
|
ret
|
||
|
got_tank:
|
||
|
ld a,(item)
|
||
|
cp 1
|
||
|
ret nz
|
||
|
inc a
|
||
|
ld (item),a
|
||
|
ld a,(tanks)
|
||
|
inc a
|
||
|
ld (tanks),a
|
||
|
ret
|
||
|
jump:
|
||
|
push af
|
||
|
ld a,(jchk)
|
||
|
cp 2
|
||
|
jr z,no_jump
|
||
|
or a
|
||
|
jr nz,jump_up
|
||
|
ld a,1
|
||
|
ld (jchk),a
|
||
|
ld a,(ymm)
|
||
|
sub 10
|
||
|
jr nc,jrem_not0
|
||
|
ld a,1
|
||
|
jrem_not0:
|
||
|
ld (jrem),a
|
||
|
jump_up:
|
||
|
ld a,(jrem)
|
||
|
ld b,a
|
||
|
ld a,(ymm)
|
||
|
cp b
|
||
|
jr c,end_jump
|
||
|
call CheckUp
|
||
|
call z,CheckUp2
|
||
|
jr nz,end_jump
|
||
|
ld a,(ymm)
|
||
|
dec a
|
||
|
ld (ymm),a
|
||
|
jr no_jump
|
||
|
end_jump:
|
||
|
ld a,2
|
||
|
ld (jchk),a
|
||
|
no_jump:
|
||
|
pop af
|
||
|
ret
|
||
|
fall:
|
||
|
push af
|
||
|
ld a,(jchk)
|
||
|
cp 1
|
||
|
jr z,no_fall
|
||
|
call CheckDown
|
||
|
call z,CheckDown2
|
||
|
jr nz,end_fall
|
||
|
ld a,(ymm)
|
||
|
inc a
|
||
|
ld (ymm),a
|
||
|
cp 52
|
||
|
call z,die
|
||
|
jr no_fall
|
||
|
end_fall:
|
||
|
xor a
|
||
|
ld (jchk),a
|
||
|
no_fall:
|
||
|
pop af
|
||
|
ret
|
||
|
CheckUp:
|
||
|
ld a,(ymm)
|
||
|
dec a
|
||
|
jr CheckVert
|
||
|
CheckDown:
|
||
|
ld a,(ymm)
|
||
|
add a,12
|
||
|
CheckVert:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
CheckUp2:
|
||
|
ld a,(ymm)
|
||
|
dec a
|
||
|
jr CheckVert2
|
||
|
CheckDown2:
|
||
|
ld a,(ymm)
|
||
|
add a,12
|
||
|
CheckVert2:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld de,7
|
||
|
add hl,de
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
shoot_sa:
|
||
|
ld a,(xmm)
|
||
|
ld (wx1),a
|
||
|
ld a,(ymm)
|
||
|
add a,4
|
||
|
ld (wy1),a
|
||
|
ld a,1
|
||
|
ld (wchk1),a
|
||
|
ld a,(enwpn)
|
||
|
sub 4
|
||
|
ld (enwpn),a
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ret
|
||
|
shoot_fr:
|
||
|
ld a,(xmm)
|
||
|
ld (wx1),a
|
||
|
ld a,(ymm)
|
||
|
ld (wy1),a
|
||
|
call xor_wpn1
|
||
|
ld a,(wy1)
|
||
|
add a,4
|
||
|
ld (wy1),a
|
||
|
call xor_wpn1
|
||
|
ld a,(wy1)
|
||
|
add a,4
|
||
|
ld (wy1),a
|
||
|
ld a,1
|
||
|
ld (wchk1),a
|
||
|
ld a,(enwpn)
|
||
|
sub 4
|
||
|
ld (enwpn),a
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ret
|
||
|
shoot_md:
|
||
|
ld a,(ymm)
|
||
|
inc a
|
||
|
ld (wy1),a
|
||
|
ld a,(dir)
|
||
|
or a
|
||
|
ld a,(xmm)
|
||
|
jr z,smd_left
|
||
|
add a,8
|
||
|
jr smd_right
|
||
|
smd_left:
|
||
|
sub 8
|
||
|
smd_right:
|
||
|
ld (wx1),a
|
||
|
ld a,1
|
||
|
ld (wchk1),a
|
||
|
ld a,(enwpn)
|
||
|
sub 4
|
||
|
ld (enwpn),a
|
||
|
ret
|
||
|
shoot_se:
|
||
|
ld a,(bchk) ; restrictions on using top secret weapon
|
||
|
or a
|
||
|
ret nz
|
||
|
ld a,(echk)
|
||
|
or a
|
||
|
ret z
|
||
|
cp 3
|
||
|
ret z
|
||
|
ld a,(ymm)
|
||
|
cp 26
|
||
|
ret c
|
||
|
ld a,(lives)
|
||
|
cp 3
|
||
|
ret c
|
||
|
ld a,(tanks)
|
||
|
cp 4
|
||
|
ret c
|
||
|
call won ; effect is beating the current part of the level if requirements are met
|
||
|
xor a
|
||
|
ld (enwpn),a
|
||
|
ret
|
||
|
shoot:
|
||
|
ld a,(wchk)
|
||
|
or a
|
||
|
ret nz
|
||
|
ld a,(wpn)
|
||
|
or a
|
||
|
jr z,no_check_enwpn
|
||
|
ld a,(enwpn) ; don't shoot if no weapon energy left
|
||
|
or a
|
||
|
ret z
|
||
|
no_check_enwpn:
|
||
|
ld a,(dir) ; make sure you aren't too close to edge of screen
|
||
|
or a
|
||
|
jr z,try_left
|
||
|
ld a,(xmm)
|
||
|
cp 80
|
||
|
ret nc
|
||
|
jr shoot_cont
|
||
|
try_left:
|
||
|
ld a,(xmm)
|
||
|
cp 8
|
||
|
ret c
|
||
|
shoot_cont:
|
||
|
ld a,(wpn)
|
||
|
cp 3
|
||
|
jr z,shoot_md
|
||
|
cp 5
|
||
|
jr z,shoot_se
|
||
|
cp 7
|
||
|
jp z,shoot_fr
|
||
|
cp 8
|
||
|
jp z,shoot_sa
|
||
|
ld a,1
|
||
|
ld (wchk),a
|
||
|
ld a,(wpn)
|
||
|
or a
|
||
|
jr z,no_dec_enwpn
|
||
|
ld a,(enwpn)
|
||
|
dec a
|
||
|
ld (enwpn),a
|
||
|
no_dec_enwpn:
|
||
|
ld a,(wchk1) ; check for bullet #1
|
||
|
or a ; if it doesn't exist, it does now
|
||
|
jr z,store_shot1
|
||
|
ld a,(wchk2) ; check for bullet #2
|
||
|
or a ; if it doesn't exist, it does now
|
||
|
jr z,store_shot2
|
||
|
ld a,(wchk3) ; check for bullet #3
|
||
|
or a ; if it doesn't exist, it does now
|
||
|
ret nz
|
||
|
ld a,(ymm) ; initialize shot #3
|
||
|
add a,5
|
||
|
ld (wy3),a
|
||
|
ld a,(dir)
|
||
|
ld (wdir3),a
|
||
|
or a
|
||
|
jr z,shoot_left3
|
||
|
ld a,(xmm)
|
||
|
add a,8
|
||
|
ld b,a
|
||
|
add a,12
|
||
|
jr shoot_init3
|
||
|
shoot_left3:
|
||
|
ld a,(xmm)
|
||
|
sub 8
|
||
|
ld b,a
|
||
|
sub 12
|
||
|
shoot_init3:
|
||
|
res 0,a
|
||
|
ld (wrem3),a
|
||
|
ld a,b
|
||
|
ld (wx3),a
|
||
|
ld a,1
|
||
|
ld (wchk3),a
|
||
|
ret
|
||
|
store_shot2:
|
||
|
ld a,(ymm) ; initialize shot #2
|
||
|
add a,5
|
||
|
ld (wy2),a
|
||
|
ld a,(dir)
|
||
|
ld (wdir2),a
|
||
|
or a
|
||
|
jr z,shoot_left2
|
||
|
ld a,(xmm)
|
||
|
add a,8
|
||
|
ld b,a
|
||
|
add a,24
|
||
|
jr shoot_init2
|
||
|
shoot_left2:
|
||
|
ld a,(xmm)
|
||
|
sub 8
|
||
|
ld b,a
|
||
|
sub 24
|
||
|
shoot_init2:
|
||
|
res 0,a
|
||
|
ld (wrem2),a
|
||
|
ld a,b
|
||
|
ld (wx2),a
|
||
|
ld a,1
|
||
|
ld (wchk2),a
|
||
|
ret
|
||
|
store_shot1:
|
||
|
ld a,(ymm) ; initialize shot #1
|
||
|
add a,5
|
||
|
ld (wy1),a
|
||
|
ld a,(dir)
|
||
|
ld (wdir1),a
|
||
|
or a
|
||
|
jr z,shoot_left1
|
||
|
ld a,(xmm)
|
||
|
add a,8
|
||
|
ld b,a
|
||
|
add a,24
|
||
|
jr shoot_init1
|
||
|
shoot_left1:
|
||
|
ld a,(xmm)
|
||
|
sub 8
|
||
|
ld b,a
|
||
|
sub 24
|
||
|
shoot_init1:
|
||
|
res 0,a
|
||
|
ld (wrem1),a
|
||
|
ld a,b
|
||
|
ld (wx1),a
|
||
|
ld a,1
|
||
|
ld (wchk1),a
|
||
|
ret
|
||
|
shot3_move:
|
||
|
call xor_wpn3
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(wx3)
|
||
|
cp 4
|
||
|
jr c,sm_end3
|
||
|
cp 87
|
||
|
jr nc,sm_end3
|
||
|
res 0,a
|
||
|
cp b
|
||
|
jr z,sm_end3
|
||
|
ld b,a
|
||
|
ld a,(wpn)
|
||
|
cp 1
|
||
|
jr z,sm_short3
|
||
|
cp 2
|
||
|
jr z,sm_short3
|
||
|
cp 6
|
||
|
jr z,sm_short3
|
||
|
sm_cont3:
|
||
|
ld a,(wdir3)
|
||
|
or a
|
||
|
ld a,(wpn)
|
||
|
jr z,sm_left3
|
||
|
inc b
|
||
|
inc b
|
||
|
or a
|
||
|
jr z,smr_two3
|
||
|
cp 4
|
||
|
jr z,smr_two3
|
||
|
cp 6
|
||
|
jr z,smr_two3
|
||
|
jr sm_store3
|
||
|
smr_two3:
|
||
|
inc b
|
||
|
jr sm_store3
|
||
|
sm_left3:
|
||
|
dec b
|
||
|
dec b
|
||
|
or a
|
||
|
jr z,sml_two3
|
||
|
cp 4
|
||
|
jr z,sml_two3
|
||
|
cp 6
|
||
|
jr z,sml_two3
|
||
|
sml_two3:
|
||
|
dec b
|
||
|
sm_store3:
|
||
|
ld a,b
|
||
|
ld (wx3),a
|
||
|
ret
|
||
|
sm_short3:
|
||
|
ld a,(wrem3)
|
||
|
res 0,a
|
||
|
sub b
|
||
|
jr nz,sm_cont3
|
||
|
ld a,(wpn)
|
||
|
cp 6
|
||
|
jr z,sm_chg3
|
||
|
sm_end3:
|
||
|
xor a ; shot is off the screen
|
||
|
ld (wchk3),a
|
||
|
ret
|
||
|
sm_chg3:
|
||
|
ld a,(wdir3) ; reverse dir shot #3 is moving
|
||
|
inc a
|
||
|
and $01
|
||
|
ld (wdir3),a
|
||
|
jr sm_cont3
|
||
|
shot2_move:
|
||
|
call xor_wpn2
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(wx2)
|
||
|
cp 4
|
||
|
jr c,sm_end2
|
||
|
cp 87
|
||
|
jr nc,sm_end2
|
||
|
res 0,a
|
||
|
cp b
|
||
|
jr z,sm_end2
|
||
|
ld b,a
|
||
|
ld a,(wpn)
|
||
|
cp 1
|
||
|
jr z,sm_short2
|
||
|
cp 2
|
||
|
jr z,sm_short2
|
||
|
cp 6
|
||
|
jr z,sm_short2
|
||
|
sm_cont2:
|
||
|
ld a,(wdir2)
|
||
|
or a
|
||
|
ld a,(wpn)
|
||
|
jr z,sm_left2
|
||
|
inc b
|
||
|
inc b
|
||
|
or a
|
||
|
jr z,smr_two2
|
||
|
cp 4
|
||
|
jr z,smr_two2
|
||
|
cp 6
|
||
|
jr z,smr_two2
|
||
|
jr sm_store2
|
||
|
smr_two2:
|
||
|
inc b
|
||
|
jr sm_store2
|
||
|
sm_left2:
|
||
|
dec b
|
||
|
dec b
|
||
|
or a
|
||
|
jr z,sml_two2
|
||
|
cp 4
|
||
|
jr z,sml_two2
|
||
|
cp 6
|
||
|
jr z,sml_two2
|
||
|
sml_two2:
|
||
|
dec b
|
||
|
sm_store2:
|
||
|
ld a,b
|
||
|
ld (wx2),a
|
||
|
ret
|
||
|
sm_short2:
|
||
|
ld a,(wrem2)
|
||
|
res 0,a
|
||
|
sub b
|
||
|
jr nz,sm_cont2
|
||
|
ld a,(wpn)
|
||
|
cp 6
|
||
|
jr z,sm_chg2
|
||
|
sm_end2:
|
||
|
xor a ; shot is off the screen
|
||
|
ld (wchk2),a
|
||
|
ret
|
||
|
sm_chg2:
|
||
|
ld a,(wdir2) ; reverse dir shot #2 is moving
|
||
|
inc a
|
||
|
and $01
|
||
|
ld (wdir2),a
|
||
|
jr sm_cont2
|
||
|
ssa_move:
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ssam_loop:
|
||
|
ld a,(wx1)
|
||
|
inc a
|
||
|
ld (wx1),a
|
||
|
call xor_wpn1
|
||
|
call fastcopys
|
||
|
call xor_wpn1
|
||
|
ld a,(wx1)
|
||
|
cp 88
|
||
|
jr nz,ssam_loop
|
||
|
ssam_loop2:
|
||
|
ld a,(wx1)
|
||
|
dec a
|
||
|
ld (wx1),a
|
||
|
call xor_wpn1
|
||
|
call fastcopys
|
||
|
call xor_wpn1
|
||
|
ld a,(wx1)
|
||
|
or a
|
||
|
jr nz,ssam_loop2
|
||
|
ssam_loop3:
|
||
|
ld a,(wx1)
|
||
|
inc a
|
||
|
ld (wx1),a
|
||
|
call xor_wpn1
|
||
|
call fastcopys
|
||
|
call xor_wpn1
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(wx1)
|
||
|
cp b
|
||
|
jr nz,ssam_loop3
|
||
|
xor a
|
||
|
ld (wchk1),a
|
||
|
ld a,(echk)
|
||
|
or a
|
||
|
jr z,ssam_bchk
|
||
|
cp 3
|
||
|
jr z,ssam_bchk
|
||
|
ld a,(ye)
|
||
|
ld b,a
|
||
|
ld a,(wy1)
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,10
|
||
|
cp b
|
||
|
ret c
|
||
|
xor a
|
||
|
ld a,(ene)
|
||
|
or a
|
||
|
sub 2
|
||
|
jr nc,sahite_nokill
|
||
|
xor a
|
||
|
sahite_nokill:
|
||
|
ld (ene),a
|
||
|
or a
|
||
|
ret nz
|
||
|
ld a,3
|
||
|
ld (echk),a
|
||
|
ret
|
||
|
ssam_bchk:
|
||
|
ld a,(bchk)
|
||
|
or a
|
||
|
ret z
|
||
|
ld a,(yb)
|
||
|
ld b,a
|
||
|
ld a,(wy1)
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
call dam7_or1
|
||
|
ld a,(enb)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,sahitb_nokill
|
||
|
xor a
|
||
|
sahitb_nokill:
|
||
|
ld (enb),a
|
||
|
ret nz
|
||
|
call won
|
||
|
ret
|
||
|
sfr_move:
|
||
|
ld a,(wy1)
|
||
|
sub 4
|
||
|
ld (wy1),a
|
||
|
call xor_wpn1
|
||
|
ld a,(wy1)
|
||
|
sub 4
|
||
|
ld (wy1),a
|
||
|
call xor_wpn1
|
||
|
call short_delay
|
||
|
xor a
|
||
|
ld (wchk1),a
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ld a,(echk)
|
||
|
or a
|
||
|
jr z,sfrm_bchk
|
||
|
cp 3
|
||
|
jr z,sfrm_bchk
|
||
|
ld a,(xe)
|
||
|
ld b,a
|
||
|
ld a,(wx1)
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,22
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ye)
|
||
|
ld b,a
|
||
|
ld a,(wy1)
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,10
|
||
|
cp b
|
||
|
ret c
|
||
|
xor a
|
||
|
ld a,(ene)
|
||
|
or a
|
||
|
sub 2
|
||
|
jr nc,frhite_nokill
|
||
|
xor a
|
||
|
frhite_nokill:
|
||
|
ld (ene),a
|
||
|
or a
|
||
|
ret nz
|
||
|
ld a,3
|
||
|
ld (echk),a
|
||
|
ret
|
||
|
sfrm_bchk:
|
||
|
ld a,(bchk)
|
||
|
or a
|
||
|
ret z
|
||
|
ld a,(xb)
|
||
|
ld b,a
|
||
|
ld a,(wx1)
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,22
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(yb)
|
||
|
ld b,a
|
||
|
ld a,(wy1)
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
call dam7_or1
|
||
|
ld a,(enb)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,frhitb_nokill
|
||
|
xor a
|
||
|
frhitb_nokill:
|
||
|
ld (enb),a
|
||
|
ret nz
|
||
|
call won
|
||
|
ret
|
||
|
smd_move:
|
||
|
call short_delay
|
||
|
xor a
|
||
|
ld (wchk1),a
|
||
|
ld a,(echk)
|
||
|
or a
|
||
|
jr z,smdm_bchk
|
||
|
cp 3
|
||
|
jr z,smdm_bchk
|
||
|
call xor_en
|
||
|
ld a,3
|
||
|
ld (echk),a
|
||
|
xor a
|
||
|
ld (ecount),a
|
||
|
smdm_bchk:
|
||
|
ld a,(bchk)
|
||
|
or a
|
||
|
ret z
|
||
|
call dam7_or1
|
||
|
ld a,(enb)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,mdhitb_nokill
|
||
|
xor a
|
||
|
mdhitb_nokill:
|
||
|
ld (enb),a
|
||
|
ret nz
|
||
|
call won
|
||
|
ret
|
||
|
shot1_move:
|
||
|
call xor_wpn1
|
||
|
ld a,(wpn)
|
||
|
cp 3
|
||
|
jr z,smd_move
|
||
|
cp 7
|
||
|
jp z,sfr_move
|
||
|
cp 8
|
||
|
jp z,ssa_move
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(wx1)
|
||
|
cp 4
|
||
|
jr c,sm_end1
|
||
|
cp 87
|
||
|
jr nc,sm_end1
|
||
|
res 0,a
|
||
|
cp b
|
||
|
jr z,sm_end1
|
||
|
ld b,a
|
||
|
ld a,(wpn)
|
||
|
cp 1
|
||
|
jr z,sm_short1
|
||
|
cp 2
|
||
|
jr z,sm_short1
|
||
|
cp 6
|
||
|
jr z,sm_short1
|
||
|
sm_cont1:
|
||
|
ld a,(wdir1)
|
||
|
or a
|
||
|
ld a,(wpn)
|
||
|
jr z,sm_left1
|
||
|
inc b
|
||
|
inc b
|
||
|
or a
|
||
|
jr z,smr_two1
|
||
|
cp 4
|
||
|
jr z,smr_two1
|
||
|
cp 6
|
||
|
jr z,smr_two1
|
||
|
jr sm_store1
|
||
|
smr_two1:
|
||
|
inc b
|
||
|
jr sm_store1
|
||
|
sm_left1:
|
||
|
dec b
|
||
|
dec b
|
||
|
or a
|
||
|
jr z,sml_two1
|
||
|
cp 4
|
||
|
jr z,sml_two1
|
||
|
cp 6
|
||
|
jr z,sml_two1
|
||
|
sml_two1:
|
||
|
dec b
|
||
|
sm_store1:
|
||
|
ld a,b
|
||
|
ld (wx1),a
|
||
|
ret
|
||
|
sm_short1:
|
||
|
ld a,(wrem1)
|
||
|
res 0,a
|
||
|
sub b
|
||
|
jr nz,sm_cont1
|
||
|
ld a,(wpn)
|
||
|
cp 6
|
||
|
jr z,sm_chg1
|
||
|
sm_end1:
|
||
|
xor a ; shot is off the screen
|
||
|
ld (wchk1),a
|
||
|
ret
|
||
|
sm_chg1:
|
||
|
ld a,(wdir1) ; reverse dir shot #1 is moving
|
||
|
inc a
|
||
|
and $01
|
||
|
ld (wdir1),a
|
||
|
jr sm_cont1
|
||
|
inc_wchk: ; lets you shoot again
|
||
|
inc a
|
||
|
cp 8
|
||
|
jr nz,keep_wchk
|
||
|
xor a
|
||
|
keep_wchk:
|
||
|
ld (wchk),a
|
||
|
ret
|
||
|
die:
|
||
|
call short_delay
|
||
|
ld a,(lives)
|
||
|
dec a
|
||
|
ld (lives),a
|
||
|
ld a,1
|
||
|
ld (death),a
|
||
|
ret
|
||
|
won:
|
||
|
ld a,1
|
||
|
ld (win),a
|
||
|
ld a,(bchk) ; check for boss
|
||
|
or a
|
||
|
ret z
|
||
|
ld a,(boss) ; see if that boss was the spaceship
|
||
|
cp 5
|
||
|
ret nz
|
||
|
ld a,2 ; if so, set win=2
|
||
|
ld (win),a
|
||
|
ret
|
||
|
s1_dec:
|
||
|
ld a,(wx1)
|
||
|
dec a
|
||
|
ld (wx1),a
|
||
|
ld a,(wrem1)
|
||
|
dec a
|
||
|
ld (wrem1),a
|
||
|
ret
|
||
|
s2_dec:
|
||
|
ld a,(wx2)
|
||
|
dec a
|
||
|
ld (wx2),a
|
||
|
ld a,(wrem2)
|
||
|
dec a
|
||
|
ld (wrem2),a
|
||
|
ret
|
||
|
s3_dec:
|
||
|
ld a,(wx3)
|
||
|
dec a
|
||
|
ld (wx3),a
|
||
|
ld a,(wrem3)
|
||
|
dec a
|
||
|
ld (wrem3),a
|
||
|
ret
|
||
|
scroll:
|
||
|
bcall(_grbufclr)
|
||
|
ld a,(tempscr)
|
||
|
inc a
|
||
|
cp 8
|
||
|
jr nz,scroll_cont
|
||
|
ld a,(xscr)
|
||
|
inc a
|
||
|
ld (xscr),a
|
||
|
xor a
|
||
|
scroll_cont:
|
||
|
ld (tempscr),a
|
||
|
ld a,(wchk1)
|
||
|
or a
|
||
|
call nz,s1_dec
|
||
|
ld a,(wchk2)
|
||
|
or a
|
||
|
call nz,s2_dec
|
||
|
ld a,(wchk3)
|
||
|
or a
|
||
|
call nz,s3_dec
|
||
|
ld a,(echk)
|
||
|
or a
|
||
|
call nz,next_en
|
||
|
ld a,(echk)
|
||
|
or a
|
||
|
ret z
|
||
|
cp 3
|
||
|
ret z
|
||
|
ld a,(xe) ; decrease x-coord of enemy
|
||
|
dec a
|
||
|
ld (xe),a
|
||
|
or a
|
||
|
call z,en_dead
|
||
|
ret
|
||
|
ShowLevel:
|
||
|
ld hl,(xscr)
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
push hl
|
||
|
pop de
|
||
|
ld hl,(curlvl)
|
||
|
add hl,de
|
||
|
ld bc,0
|
||
|
RepShowLevel: ; displays the current full screen of the level
|
||
|
ld a,(hl)
|
||
|
cp 5
|
||
|
call nc,item_init
|
||
|
inc hl
|
||
|
push hl
|
||
|
ld h,0
|
||
|
ld l,a
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
ld de,lvlspr
|
||
|
add hl,de
|
||
|
push bc
|
||
|
ld a,(tempscr)
|
||
|
ld d,a
|
||
|
ld a,b
|
||
|
sub d
|
||
|
jr c,skip_8x8
|
||
|
ld (x2),a
|
||
|
ld a,c
|
||
|
ld (y2),a
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
skip_8x8:
|
||
|
pop bc
|
||
|
pop hl
|
||
|
ld a,c
|
||
|
add a,8
|
||
|
ld c,a
|
||
|
cp 64
|
||
|
jr nz,RepShowLevel
|
||
|
ld c,0
|
||
|
ld a,b
|
||
|
add a,8
|
||
|
ld b,a
|
||
|
cp 96
|
||
|
jr nz,RepShowLevel
|
||
|
ret
|
||
|
item_init:
|
||
|
ld d,a
|
||
|
cp 7
|
||
|
jr nc,t_init
|
||
|
ld a,(item)
|
||
|
cp 2
|
||
|
jr z,no_item_init
|
||
|
ld a,1
|
||
|
ld (item),a
|
||
|
ld a,d
|
||
|
ret
|
||
|
no_item_init:
|
||
|
xor a ; replace item sprite with blank sprite
|
||
|
ret
|
||
|
t_init:
|
||
|
ld a,(echk) ; check for existing enemy
|
||
|
or a
|
||
|
jr nz,no_en_init
|
||
|
ld hl,iup ; initialize enemy variables
|
||
|
xor a
|
||
|
ld (edir),a
|
||
|
ld (ecount),a
|
||
|
ld (ecount2),a
|
||
|
inc a
|
||
|
inc a
|
||
|
ld (ene),a
|
||
|
ld a,d
|
||
|
cp 9
|
||
|
ld a,1
|
||
|
jr z,i_init
|
||
|
ld a,3
|
||
|
ld (ene),a
|
||
|
dec a
|
||
|
ld hl,tleft
|
||
|
i_init:
|
||
|
ld (echk),a
|
||
|
ld (enspr),hl
|
||
|
ld a,b
|
||
|
ld (xe),a
|
||
|
ld a,c
|
||
|
ld (ye),a
|
||
|
no_en_init:
|
||
|
xor a ; replace enemy sprite with blank sprite
|
||
|
ret
|
||
|
load_x: ; loads x location (input as hl) into hl, accounting for scrolling
|
||
|
push hl
|
||
|
ld hl,(xscr)
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
pop de
|
||
|
add hl,de
|
||
|
push hl
|
||
|
ld hl,(tempscr)
|
||
|
pop de
|
||
|
add hl,de
|
||
|
ret
|
||
|
feet_inc: ; feet changes from 0 to 1 to 2 to 3 to 0
|
||
|
ld a,(feet)
|
||
|
inc a
|
||
|
cp 4
|
||
|
jr nz,store_feet
|
||
|
xor a
|
||
|
store_feet:
|
||
|
ld (feet),a
|
||
|
ret
|
||
|
sub_screen:
|
||
|
push af
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
call tiny_delay
|
||
|
xor a
|
||
|
ld (wchk1),a
|
||
|
ld (wchk2),a
|
||
|
ld (wchk3),a
|
||
|
ld a,(wpn)
|
||
|
or a
|
||
|
jr z,ss_cont
|
||
|
cp 1
|
||
|
jr z,en_an
|
||
|
cp 2
|
||
|
jr z,en_ma
|
||
|
cp 3
|
||
|
jr z,en_md
|
||
|
cp 4
|
||
|
jr z,en_do
|
||
|
cp 5
|
||
|
jr z,en_se
|
||
|
cp 6
|
||
|
jr z,en_po
|
||
|
cp 7
|
||
|
jr z,en_fr
|
||
|
cp 8
|
||
|
jr z,en_sa
|
||
|
cp 9
|
||
|
jr z,en_mi
|
||
|
en_an:
|
||
|
ld a,(enwpn)
|
||
|
ld (enan),a
|
||
|
jr ss_cont
|
||
|
en_ma:
|
||
|
ld a,(enwpn)
|
||
|
ld (enma),a
|
||
|
jr ss_cont
|
||
|
en_md:
|
||
|
ld a,(enwpn)
|
||
|
ld (enmd),a
|
||
|
jr ss_cont
|
||
|
en_do:
|
||
|
ld a,(enwpn)
|
||
|
ld (endo),a
|
||
|
jr ss_cont
|
||
|
en_se:
|
||
|
ld a,(enwpn)
|
||
|
ld (ense),a
|
||
|
jr ss_cont
|
||
|
en_po:
|
||
|
ld a,(enwpn)
|
||
|
ld (enpo),a
|
||
|
jr ss_cont
|
||
|
en_fr:
|
||
|
ld a,(enwpn)
|
||
|
ld (enfr),a
|
||
|
jr ss_cont
|
||
|
en_sa:
|
||
|
ld a,(enwpn)
|
||
|
ld (ensa),a
|
||
|
jr ss_cont
|
||
|
en_mi:
|
||
|
ld a,(enwpn)
|
||
|
ld (enmi),a
|
||
|
ss_cont:
|
||
|
ld a,28
|
||
|
ld (x2),a
|
||
|
ld a,53
|
||
|
ld (y2),a
|
||
|
ld hl,tank
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld a,55
|
||
|
ld (x2),a
|
||
|
ld hl,head
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld hl,ss_cont_lindat
|
||
|
call draw
|
||
|
xor a
|
||
|
ld (x2),a
|
||
|
inc a
|
||
|
ld (y2),a
|
||
|
ld hl,pwdot
|
||
|
ld (smlspr),hl
|
||
|
ss_loop_new:
|
||
|
call xor_8x8
|
||
|
call fastcopys
|
||
|
ld a,(lvldone)
|
||
|
bit 0,a
|
||
|
jr z,ss_line1
|
||
|
ld d,16
|
||
|
ld e,15
|
||
|
push af
|
||
|
ld a,(enan)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,15
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line1:
|
||
|
bit 1,a
|
||
|
jr z,ss_line2
|
||
|
ld d,16
|
||
|
ld e,25
|
||
|
push af
|
||
|
ld a,(enma)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,25
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line2:
|
||
|
bit 2,a
|
||
|
jr z,ss_line3
|
||
|
ld d,16
|
||
|
ld e,35
|
||
|
push af
|
||
|
ld a,(enmd)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,35
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line3:
|
||
|
bit 3,a
|
||
|
jr z,ss_line4
|
||
|
ld d,16
|
||
|
ld e,45
|
||
|
push af
|
||
|
ld a,(endo)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,45
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line4:
|
||
|
bit 4,a
|
||
|
jr z,ss_line5
|
||
|
ld d,63
|
||
|
ld e,15
|
||
|
push af
|
||
|
ld a,(enpo)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,15
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line5:
|
||
|
bit 5,a
|
||
|
jr z,ss_line6
|
||
|
ld d,63
|
||
|
ld e,5
|
||
|
push af
|
||
|
ld a,(ense)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,5
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ld d,63
|
||
|
ld e,25
|
||
|
ld a,(enfr)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,25
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line6:
|
||
|
bit 6,a
|
||
|
jr z,ss_line7
|
||
|
ld d,63
|
||
|
ld e,35
|
||
|
push af
|
||
|
ld a,(ensa)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,35
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line7:
|
||
|
bit 7,a
|
||
|
jr z,ss_line_done
|
||
|
ld d,63
|
||
|
ld e,45
|
||
|
ld a,(enmi)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,45
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ss_line_done:
|
||
|
ld d,16
|
||
|
ld e,5
|
||
|
ld a,(enp)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,5
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
call fastcopys
|
||
|
ld a,(lvldone)
|
||
|
bit 0,a
|
||
|
jr z,ss_bit1
|
||
|
ld de,12*256+7
|
||
|
ld hl,an
|
||
|
call setvputs
|
||
|
ss_bit1:
|
||
|
bit 1,a
|
||
|
jr z,ss_bit2
|
||
|
ld de,22*256+7
|
||
|
ld hl,ma
|
||
|
call setvputs
|
||
|
ss_bit2:
|
||
|
bit 2,a
|
||
|
jr z,ss_bit3
|
||
|
ld de,32*256+7
|
||
|
ld hl,md
|
||
|
call setvputs
|
||
|
ss_bit3:
|
||
|
bit 3,a
|
||
|
jr z,ss_bit4
|
||
|
ld de,42*256+7
|
||
|
ld hl,do
|
||
|
call setvputs
|
||
|
ss_bit4:
|
||
|
bit 4,a
|
||
|
jr z,ss_bit5
|
||
|
ld de,12*256+54
|
||
|
ld hl,po
|
||
|
call setvputs
|
||
|
ss_bit5:
|
||
|
bit 5,a
|
||
|
jr z,ss_bit6
|
||
|
ld de,22*256+54
|
||
|
ld hl,fr
|
||
|
call setvputs
|
||
|
ld de,2*256+54
|
||
|
ld hl,se
|
||
|
call setvputs
|
||
|
ss_bit6:
|
||
|
bit 6,a
|
||
|
jr z,ss_bit7
|
||
|
ld de,32*256+54
|
||
|
ld hl,sa
|
||
|
call setvputs
|
||
|
ss_bit7:
|
||
|
bit 7,a
|
||
|
jr z,ss_loop_init
|
||
|
ld de,42*256+54
|
||
|
ld hl,mi
|
||
|
call setvputs
|
||
|
ss_loop_init:
|
||
|
ld de,2*256+7
|
||
|
ld hl,p
|
||
|
call setvputs
|
||
|
ld a,(tanks)
|
||
|
bcall(_setxxop1
|
||
|
ld hl,54*256+40
|
||
|
ld (pencol),hl
|
||
|
ld a,1
|
||
|
bcall(_dispop1a)
|
||
|
ld a,(lives)
|
||
|
bcall(_setxxop1)
|
||
|
ld hl,54*256+67
|
||
|
ld (pencol),hl
|
||
|
ld a,1
|
||
|
bcall(_dispop1a)
|
||
|
call xor_8x8
|
||
|
ss_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp kUp
|
||
|
jp z,ss_up
|
||
|
cp kDown
|
||
|
jp z,ss_down
|
||
|
cp kLeft
|
||
|
jp z,ss_horz
|
||
|
cp kRight
|
||
|
jp z,ss_horz
|
||
|
cp k2nd
|
||
|
jp z,ss_tank
|
||
|
cp kMode
|
||
|
jp z,ss_mode
|
||
|
cp kYEq
|
||
|
jr nz,ss_loop
|
||
|
ld hl,wpp
|
||
|
ld a,(lvldone)
|
||
|
ld b,a
|
||
|
ld a,(x2)
|
||
|
or a
|
||
|
ld a,(y2)
|
||
|
jr z,wpn_left
|
||
|
cp 1
|
||
|
jr z,ss_se
|
||
|
cp 11
|
||
|
jp z,ss_po
|
||
|
cp 21
|
||
|
jp z,ss_fr
|
||
|
cp 31
|
||
|
jp z,ss_sa
|
||
|
jp ss_mi
|
||
|
wpn_left:
|
||
|
ld c,0
|
||
|
ld hl,wpp
|
||
|
cp 1
|
||
|
jp z,ss_exit
|
||
|
cp 11
|
||
|
jr z,ss_an
|
||
|
cp 21
|
||
|
jr z,ss_ma
|
||
|
cp 31
|
||
|
jr z,ss_md
|
||
|
jr ss_do
|
||
|
ss_an:
|
||
|
bit 0,b
|
||
|
jr z,ss_loop
|
||
|
ld c,1
|
||
|
ld a,(enan)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wpan
|
||
|
jp ss_exit
|
||
|
ss_ma:
|
||
|
bit 1,b
|
||
|
jr z,ss_loop
|
||
|
ld c,2
|
||
|
ld a,(enma)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wpma
|
||
|
jr ss_exit
|
||
|
ss_md:
|
||
|
bit 2,b
|
||
|
jp z,ss_loop
|
||
|
ld c,3
|
||
|
ld a,(enmd)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wpmd
|
||
|
jr ss_exit
|
||
|
ss_do:
|
||
|
bit 3,b
|
||
|
jp z,ss_loop
|
||
|
ld c,4
|
||
|
ld a,(endo)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wpdo
|
||
|
jr ss_exit
|
||
|
ss_se:
|
||
|
bit 5,b
|
||
|
jp z,ss_loop
|
||
|
ld c,5
|
||
|
ld a,(ense)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wpse
|
||
|
jr ss_exit
|
||
|
ss_po:
|
||
|
bit 4,b
|
||
|
jp z,ss_loop
|
||
|
ld c,6
|
||
|
ld a,(enpo)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wppo
|
||
|
jr ss_exit
|
||
|
ss_fr:
|
||
|
bit 5,b
|
||
|
jp z,ss_loop
|
||
|
ld c,7
|
||
|
ld a,(enfr)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wpfr
|
||
|
jr ss_exit
|
||
|
ss_sa:
|
||
|
bit 6,b
|
||
|
jp z,ss_loop
|
||
|
ld c,8
|
||
|
ld a,(ensa)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wpsa
|
||
|
jr ss_exit
|
||
|
ss_mi:
|
||
|
bit 7,b
|
||
|
jp z,ss_loop
|
||
|
ld c,9
|
||
|
ld a,(enmi)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wpmi
|
||
|
ss_exit:
|
||
|
ld a,c
|
||
|
ld (wpn),a
|
||
|
ld (wpnspr),hl
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
call ShowLevel
|
||
|
pop af
|
||
|
call tiny_delay
|
||
|
ret
|
||
|
ss_mode:
|
||
|
pop bc ; pop to something other than af so it remembers that MODE has been pressed
|
||
|
ret
|
||
|
ss_up:
|
||
|
ld a,(y2)
|
||
|
cp 1
|
||
|
jr z,ss_vert
|
||
|
sub 10
|
||
|
ld (y2),a
|
||
|
jp ss_loop_new
|
||
|
ss_down:
|
||
|
ld a,(y2)
|
||
|
cp 41
|
||
|
jr z,ss_vert
|
||
|
add a,10
|
||
|
ld (y2),a
|
||
|
jp ss_loop_new
|
||
|
ss_vert:
|
||
|
ld b,a
|
||
|
ld a,42
|
||
|
sub b
|
||
|
ld (y2),a
|
||
|
jp ss_loop_new
|
||
|
ss_horz:
|
||
|
ld a,(x2)
|
||
|
ld b,a
|
||
|
ld a,47
|
||
|
sub b
|
||
|
ld (x2),a
|
||
|
jp ss_loop_new
|
||
|
ss_tank:
|
||
|
ld a,(tanks)
|
||
|
or a
|
||
|
jp z,ss_loop_new
|
||
|
dec a
|
||
|
ld (tanks),a
|
||
|
ld a,28
|
||
|
ld (enp),a
|
||
|
jp ss_loop_new
|
||
|
xor_char:
|
||
|
ld ix,(curpic)
|
||
|
ld b,12
|
||
|
ld a,(ymm)
|
||
|
ld l,a
|
||
|
ld a,(xmm)
|
||
|
call isprite
|
||
|
ret
|
||
|
check_spr:
|
||
|
ld a,(dir)
|
||
|
or a
|
||
|
jr z,check_spr_l
|
||
|
check_spr_r:
|
||
|
ld hl,mmhr
|
||
|
ld a,(hchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
ld a,(ymm)
|
||
|
add a,12
|
||
|
call CheckVert
|
||
|
jr c,not_jump_r
|
||
|
ld hl,mmjr
|
||
|
ld a,(jchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
not_jump_r:
|
||
|
ld hl,mmwr
|
||
|
ld a,(wchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
ret
|
||
|
check_spr_l:
|
||
|
ld hl,mmhl
|
||
|
ld a,(hchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
ld a,(ymm)
|
||
|
add a,12
|
||
|
call CheckVert
|
||
|
jr c,not_jump_l
|
||
|
ld hl,mmjl
|
||
|
ld a,(jchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
not_jump_l:
|
||
|
ld hl,mmwl
|
||
|
ld a,(wchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
ret
|
||
|
found_spr:
|
||
|
ld (curpic),hl
|
||
|
ret
|
||
|
find_spr:
|
||
|
ld a,(dir)
|
||
|
or a
|
||
|
jr z,left_spr
|
||
|
ld hl,mmsr
|
||
|
jr found_spr
|
||
|
left_spr:
|
||
|
ld hl,mmsl
|
||
|
jr found_spr
|
||
|
t_move:
|
||
|
call xor_en
|
||
|
call check_en_dist
|
||
|
ld a,(edir)
|
||
|
or a
|
||
|
ld a,(xe)
|
||
|
jr z,t_move_l
|
||
|
inc a
|
||
|
jr t_move_r
|
||
|
t_move_l:
|
||
|
dec a
|
||
|
or a
|
||
|
call z,en_dead
|
||
|
t_move_r:
|
||
|
ld (xe),a
|
||
|
ret
|
||
|
i_move:
|
||
|
call xor_en
|
||
|
call check_en_dist
|
||
|
ld a,(edir)
|
||
|
or a
|
||
|
ld a,(ye)
|
||
|
jr z,i_move_u
|
||
|
inc a
|
||
|
jr i_move_d
|
||
|
i_move_u:
|
||
|
dec a
|
||
|
i_move_d:
|
||
|
ld (ye),a
|
||
|
ret
|
||
|
ti_check:
|
||
|
ld a,(echk)
|
||
|
cp 3
|
||
|
jr nz,tic_cont
|
||
|
xor a
|
||
|
ld (echk),a
|
||
|
tic_cont:
|
||
|
ld b,46
|
||
|
ld c,46
|
||
|
ld a,(bcount)
|
||
|
inc a
|
||
|
ld (bcount),a
|
||
|
cp 50
|
||
|
ld a,7
|
||
|
call z,item_init
|
||
|
ld a,(bcount)
|
||
|
cp 100
|
||
|
ld a,9
|
||
|
call z,item_init
|
||
|
ld a,(bcount)
|
||
|
cp 100
|
||
|
ret nz
|
||
|
xor a
|
||
|
ld (bcount),a
|
||
|
ret
|
||
|
ship_check:
|
||
|
ld a,(bcount)
|
||
|
inc a
|
||
|
cp 50
|
||
|
jr z,ship_laser
|
||
|
ld (bcount),a
|
||
|
ret
|
||
|
ship_laser:
|
||
|
xor a
|
||
|
ld (bcount),a
|
||
|
ld b,1
|
||
|
call xor_laser
|
||
|
call short_delay
|
||
|
ld a,(ymm)
|
||
|
cp 38
|
||
|
call c,die
|
||
|
ld b,0
|
||
|
call xor_laser
|
||
|
ret
|
||
|
boss_move:
|
||
|
call xor_boss
|
||
|
ld a,(boss)
|
||
|
or a
|
||
|
jr z,ti_check
|
||
|
cp 5
|
||
|
jr z,ship_check
|
||
|
ld a,(bjchk)
|
||
|
or a
|
||
|
jr nz,boss_jump
|
||
|
ld a,(bdir)
|
||
|
or a
|
||
|
ld a,(xb)
|
||
|
jr z,boss_move_l
|
||
|
inc a
|
||
|
cp 76
|
||
|
jr boss_move_r
|
||
|
boss_move_l:
|
||
|
dec a
|
||
|
cp 56
|
||
|
boss_move_r:
|
||
|
ld (xb),a
|
||
|
jr z,boss_turn
|
||
|
cp 66
|
||
|
call z,boss_shoot
|
||
|
ret
|
||
|
boss_turn:
|
||
|
ld a,(bdir) ; reverse dir boss is moving
|
||
|
ld b,a
|
||
|
ld a,1
|
||
|
sub b
|
||
|
ld (bdir),a
|
||
|
ld a,2
|
||
|
ld (bjchk),a
|
||
|
ret
|
||
|
boss_jump:
|
||
|
ld a,(bjchk)
|
||
|
cp 1
|
||
|
ld a,(yb)
|
||
|
jr z,boss_fall
|
||
|
dec a
|
||
|
cp 34
|
||
|
jr boss_jump_end
|
||
|
boss_fall:
|
||
|
inc a
|
||
|
cp 44
|
||
|
boss_jump_end:
|
||
|
ld (yb),a
|
||
|
ret nz
|
||
|
ld a,(bjchk)
|
||
|
dec a
|
||
|
ld (bjchk),a
|
||
|
ret
|
||
|
bshoot_sa:
|
||
|
ld a,(xb)
|
||
|
ld (bwx),a
|
||
|
call xor_boss
|
||
|
ret
|
||
|
bshoot_fr:
|
||
|
ld a,(xb)
|
||
|
ld (bwx),a
|
||
|
ret
|
||
|
bshoot_md:
|
||
|
ld a,(xb)
|
||
|
sub 8
|
||
|
ld (bwx),a
|
||
|
ret
|
||
|
boss_shoot:
|
||
|
ld a,(bwchk)
|
||
|
or a
|
||
|
ret nz
|
||
|
inc a
|
||
|
ld (bwchk),a
|
||
|
ld a,(boss)
|
||
|
cp 3
|
||
|
jr z,bshoot_md
|
||
|
cp 7
|
||
|
jr z,bshoot_fr
|
||
|
cp 8
|
||
|
jr z,bshoot_sa
|
||
|
ld a,58
|
||
|
ld (bwx),a
|
||
|
ret
|
||
|
bssa_move:
|
||
|
call xor_boss
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
bssam_loop:
|
||
|
ld a,(bwx)
|
||
|
dec a
|
||
|
ld (bwx),a
|
||
|
call xor_bwpn
|
||
|
call fastcopys
|
||
|
call xor_bwpn
|
||
|
ld a,(bwx)
|
||
|
or a
|
||
|
jr nz,bssam_loop
|
||
|
bssam_loop2:
|
||
|
ld a,(bwx)
|
||
|
inc a
|
||
|
ld (bwx),a
|
||
|
call xor_bwpn
|
||
|
call fastcopys
|
||
|
call xor_bwpn
|
||
|
ld a,(bwx)
|
||
|
cp 88
|
||
|
jr nz,bssam_loop2
|
||
|
bssam_loop3:
|
||
|
ld a,(bwx)
|
||
|
dec a
|
||
|
ld (bwx),a
|
||
|
call xor_bwpn
|
||
|
call fastcopys
|
||
|
call xor_bwpn
|
||
|
ld a,(xb)
|
||
|
ld b,a
|
||
|
ld a,(bwx)
|
||
|
cp b
|
||
|
jr nz,bssam_loop3
|
||
|
xor a
|
||
|
ld (bwchk),a
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,37
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,16
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 4
|
||
|
jr nc,bssam_nokill
|
||
|
xor a
|
||
|
bssam_nokill:
|
||
|
ld (enp),a
|
||
|
ret
|
||
|
bsfr_move:
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
call xor_boss
|
||
|
call xor_bwpn
|
||
|
call fastcopys
|
||
|
call xor_char
|
||
|
call xor_boss
|
||
|
call xor_bwpn
|
||
|
call short_delay
|
||
|
xor a
|
||
|
ld (bwchk),a
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,55
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,22
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,33
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,11
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 4
|
||
|
jr nc,bsfrm_nokill
|
||
|
xor a
|
||
|
bsfrm_nokill:
|
||
|
ld (enp),a
|
||
|
ret
|
||
|
bsmd_move:
|
||
|
call short_delay
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 4
|
||
|
jr nc,bsmdm_nokill
|
||
|
xor a
|
||
|
bsmdm_nokill:
|
||
|
ld (enp),a
|
||
|
xor a
|
||
|
ld (bwchk),a
|
||
|
ret
|
||
|
boss_shot_move:
|
||
|
call xor_bwpn
|
||
|
ld a,(boss)
|
||
|
cp 8
|
||
|
jp z,bssa_move
|
||
|
cp 3
|
||
|
jr z,bsmd_move
|
||
|
cp 7
|
||
|
jr z,bsfr_move
|
||
|
ld a,(xb)
|
||
|
ld b,a
|
||
|
ld a,(bwx)
|
||
|
cp 2
|
||
|
jr c,bsm_end
|
||
|
cp b
|
||
|
jr z,bsm_end
|
||
|
ld b,a
|
||
|
bsm_cont:
|
||
|
dec b
|
||
|
dec b
|
||
|
ld a,(boss)
|
||
|
cp 4
|
||
|
jr nz,bsm_store
|
||
|
dec b
|
||
|
bsm_store:
|
||
|
ld a,b
|
||
|
ld (bwx),a
|
||
|
ret
|
||
|
bsm_end:
|
||
|
xor a ; boss's shot is off the screen
|
||
|
ld (bwchk),a
|
||
|
ret
|
||
|
check_en_dist: ; check distance enemy has moved and turn around if necessary
|
||
|
ld a,(ecount)
|
||
|
inc a
|
||
|
cp 33
|
||
|
call z,en_turn
|
||
|
ld (ecount),a
|
||
|
ret
|
||
|
en_turn:
|
||
|
ld hl,(enspr)
|
||
|
ld de,8
|
||
|
ld a,(edir)
|
||
|
or a
|
||
|
jr z,en_turn_r
|
||
|
sbc hl,de
|
||
|
dec a
|
||
|
jr en_turn_l
|
||
|
en_turn_r:
|
||
|
add hl,de
|
||
|
inc a
|
||
|
en_turn_l:
|
||
|
ld (enspr),hl
|
||
|
ld (edir),a
|
||
|
xor a
|
||
|
ret
|
||
|
en_dead: ; enemy is now dead
|
||
|
ld a,3
|
||
|
ld (echk),a
|
||
|
xor a
|
||
|
ld (ecount),a
|
||
|
ret
|
||
|
next_en: ; check if previous enemy is clear so next enemy can initialize
|
||
|
ld a,(ecount2)
|
||
|
inc a
|
||
|
ld (ecount2),a
|
||
|
cp 96
|
||
|
ret nz
|
||
|
xor a
|
||
|
ld (echk),a
|
||
|
ret
|
||
|
xor_en:
|
||
|
ld ix,(enspr)
|
||
|
ld b,8
|
||
|
ld a,(ye)
|
||
|
ld l,a
|
||
|
ld a,(xe)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_corners:
|
||
|
ld hl,uprlft
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld a,(x2)
|
||
|
add a,22
|
||
|
ld (x2),a
|
||
|
ld hl,uprrt
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld a,(y2)
|
||
|
add a,12
|
||
|
ld (y2),a
|
||
|
ld hl,lwrrt
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld a,(x2)
|
||
|
sub 22
|
||
|
ld (x2),a
|
||
|
ld hl,lwrlft
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld a,(y2)
|
||
|
sub 12
|
||
|
ld (y2),a
|
||
|
ret
|
||
|
xor_8x8:
|
||
|
ld ix,(smlspr)
|
||
|
ld b,8
|
||
|
ld a,(y2)
|
||
|
ld l,a
|
||
|
ld a,(x2)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_wpn1:
|
||
|
ld ix,(wpnspr)
|
||
|
ld b,4
|
||
|
ld a,(wy1)
|
||
|
ld l,a
|
||
|
ld a,(wx1)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_wpn2:
|
||
|
ld ix,(wpnspr)
|
||
|
ld b,4
|
||
|
ld a,(wy2)
|
||
|
ld l,a
|
||
|
ld a,(wx2)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_wpn3:
|
||
|
ld b,4
|
||
|
ld a,(wy3)
|
||
|
ld l,a
|
||
|
ld a,(wx3)
|
||
|
ld ix,(wpnspr)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_bwpn:
|
||
|
ld b,4
|
||
|
ld l,49
|
||
|
ld a,(bwx)
|
||
|
ld ix,(bwspr)
|
||
|
call isprite
|
||
|
ret
|
||
|
tiny_delay:
|
||
|
ld b,20
|
||
|
jr del_loop
|
||
|
short_delay:
|
||
|
ld b,50
|
||
|
jr del_loop
|
||
|
long_delay:
|
||
|
call delay
|
||
|
med_delay:
|
||
|
ld b,100
|
||
|
jr del_loop
|
||
|
delay:
|
||
|
ld b,200
|
||
|
del_loop:
|
||
|
halt
|
||
|
halt
|
||
|
djnz del_loop
|
||
|
ret
|
||
|
disp_boss:
|
||
|
ld (bosspic),hl
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
xor a
|
||
|
ld (x2),a
|
||
|
ld a,16
|
||
|
ld (y2),a
|
||
|
ld hl,bint
|
||
|
ld (smlspr),hl
|
||
|
ld b,12
|
||
|
draw1:
|
||
|
push bc
|
||
|
call xor_8x8
|
||
|
ld a,(x2)
|
||
|
add a,8
|
||
|
ld (x2),a
|
||
|
pop bc
|
||
|
djnz draw1
|
||
|
ld a,0
|
||
|
ld (x2),a
|
||
|
ld a,40
|
||
|
ld (y2),a
|
||
|
ld hl,bint
|
||
|
ld (smlspr),hl
|
||
|
ld b,12
|
||
|
draw2:
|
||
|
push bc
|
||
|
call xor_8x8
|
||
|
ld a,(x2)
|
||
|
add a,8
|
||
|
ld (x2),a
|
||
|
pop bc
|
||
|
djnz draw2
|
||
|
call xor_boss
|
||
|
call fastcopys
|
||
|
ret
|
||
|
xor_boss:
|
||
|
ld b,12
|
||
|
ld a,(yb)
|
||
|
ld l,a
|
||
|
ld a,(xb)
|
||
|
ld ix,(bosspic)
|
||
|
call isprite
|
||
|
ret
|
||
|
no_an:
|
||
|
ld hl,no_an_lindat
|
||
|
call draw
|
||
|
ret
|
||
|
no_ma:
|
||
|
ld hl,no_ma_lindat
|
||
|
call draw
|
||
|
ret
|
||
|
no_md:
|
||
|
ld hl,no_md_lindat
|
||
|
call draw
|
||
|
ret
|
||
|
no_do:
|
||
|
ld hl,no_do_lindat
|
||
|
call draw
|
||
|
ret
|
||
|
no_po:
|
||
|
ld hl,no_po_lindat
|
||
|
call draw
|
||
|
ret
|
||
|
no_fr:
|
||
|
ld hl,no_fr_lindat
|
||
|
call draw
|
||
|
ret
|
||
|
no_sa:
|
||
|
ld hl,no_sa_lindat
|
||
|
call draw
|
||
|
ret
|
||
|
no_mi:
|
||
|
ld hl,no_mi_lindat
|
||
|
call draw
|
||
|
ret
|
||
|
you_got:
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
ld hl,you_got_lindat
|
||
|
call draw
|
||
|
ld hl,35
|
||
|
ld (xmm),hl
|
||
|
ld a,50
|
||
|
ld (ymm),a
|
||
|
ld hl,mmsr
|
||
|
ld (curpic),hl
|
||
|
ld a,43
|
||
|
ld (wx1),a
|
||
|
ld a,51
|
||
|
ld (wy1),a
|
||
|
ld a,(boss)
|
||
|
ld hl,wpmd
|
||
|
cp 3
|
||
|
jr z,yg_cont
|
||
|
ld hl,mmwr
|
||
|
ld (curpic),hl
|
||
|
ld a,55
|
||
|
ld (wx1),a
|
||
|
ld a,55
|
||
|
ld (wy1),a
|
||
|
ld a,(boss)
|
||
|
ld hl,wpan
|
||
|
cp 1
|
||
|
jr z,yg_cont
|
||
|
ld hl,wpma
|
||
|
cp 2
|
||
|
jr z,yg_cont
|
||
|
ld hl,wpdo
|
||
|
cp 4
|
||
|
jr z,yg_cont
|
||
|
ld hl,wppo
|
||
|
cp 6
|
||
|
jr z,yg_cont
|
||
|
cp 9
|
||
|
ld hl,wpmi
|
||
|
jr z,yg_cont
|
||
|
push af
|
||
|
ld a,35
|
||
|
ld (wx1),a
|
||
|
ld a,54
|
||
|
ld (wy1),a
|
||
|
call xor_char
|
||
|
pop af
|
||
|
ld hl,wpsa
|
||
|
cp 8
|
||
|
jr z,yg_cont
|
||
|
ld hl,wpfr
|
||
|
ld (wpnspr),hl
|
||
|
call xor_wpn1
|
||
|
ld a,50
|
||
|
ld (wy1),a
|
||
|
call xor_wpn1
|
||
|
ld a,58
|
||
|
ld (wy1),a
|
||
|
ld hl,wpfr
|
||
|
yg_cont:
|
||
|
ld (wpnspr),hl
|
||
|
call xor_wpn1
|
||
|
call xor_char
|
||
|
call fastcopys
|
||
|
ld de,10*256+35
|
||
|
ld hl,yougot
|
||
|
call setvputs
|
||
|
ld a,(boss)
|
||
|
cp 1
|
||
|
jr z,yg_an
|
||
|
cp 2
|
||
|
jr z,yg_ma
|
||
|
cp 3
|
||
|
jr z,yg_md
|
||
|
cp 4
|
||
|
jr z,yg_do
|
||
|
cp 6
|
||
|
jr z,yg_po
|
||
|
cp 7
|
||
|
jr z,yg_fr
|
||
|
cp 8
|
||
|
jr z,yg_sa
|
||
|
jr yg_mi
|
||
|
yg_an:
|
||
|
ld de,20*256+28
|
||
|
ld hl,ygan
|
||
|
call setvputs
|
||
|
jr yg_loop
|
||
|
yg_ma:
|
||
|
ld de,20*256+25
|
||
|
ld hl,ygma
|
||
|
call setvputs
|
||
|
jr yg_loop
|
||
|
yg_md:
|
||
|
ld de,20*256+20
|
||
|
ld hl,ygmd
|
||
|
call setvputs
|
||
|
jr yg_loop
|
||
|
yg_do:
|
||
|
ld de,20*256+26
|
||
|
ld hl,ygdo
|
||
|
call setvputs
|
||
|
jr yg_loop
|
||
|
yg_po:
|
||
|
ld de,20*256+18
|
||
|
ld hl,ygpo
|
||
|
call setvputs
|
||
|
jr yg_loop
|
||
|
yg_fr:
|
||
|
ld de,20*256+31
|
||
|
ld hl,ygfr
|
||
|
call setvputs
|
||
|
ld de,30*256+12
|
||
|
ld hl,ygse
|
||
|
call setvputs
|
||
|
ld de,53*256+55
|
||
|
ld hl,se
|
||
|
call setvputs
|
||
|
jr yg_loop
|
||
|
yg_sa:
|
||
|
ld de,20*256+28
|
||
|
ld hl,ygsa
|
||
|
call setvputs
|
||
|
jr yg_loop
|
||
|
yg_mi:
|
||
|
ld de,20*256+28
|
||
|
ld hl,ygmi
|
||
|
call setvputs
|
||
|
yg_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp kMode
|
||
|
ret z
|
||
|
cp kEnter
|
||
|
jr nz,yg_loop
|
||
|
ret
|
||
|
draw_grid:
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
ld hl,draw_grid_lindat
|
||
|
call draw
|
||
|
ret
|
||
|
pw_text:
|
||
|
ld de,1*256+31
|
||
|
ld hl,one
|
||
|
call setvputs
|
||
|
ld de,1*256+40
|
||
|
ld hl,two
|
||
|
call setvputs
|
||
|
ld de,1*256+49
|
||
|
ld hl,three
|
||
|
call setvputs
|
||
|
ld de,1*256+58
|
||
|
ld hl,four
|
||
|
call setvputs
|
||
|
ld de,1*256+67
|
||
|
ld hl,five
|
||
|
call setvputs
|
||
|
ld de,10*256+23
|
||
|
ld hl,a
|
||
|
call setvputs
|
||
|
ld de,19*256+23
|
||
|
ld hl,b
|
||
|
call setvputs
|
||
|
ld de,28*256+23
|
||
|
ld hl,c
|
||
|
call setvputs
|
||
|
ld de,37*256+23
|
||
|
ld hl,d
|
||
|
call setvputs
|
||
|
ld de,46*256+23
|
||
|
ld hl,e
|
||
|
call setvputs
|
||
|
ld de,56*256+32
|
||
|
ld hl,enter
|
||
|
call setvputs
|
||
|
ret
|
||
|
show_pw:
|
||
|
call draw_grid
|
||
|
ld a,(tanks) ; find correct password dot for number of tanks
|
||
|
ld b,1
|
||
|
or a
|
||
|
jr z,spw_cont
|
||
|
ld b,2
|
||
|
cp 1
|
||
|
jr z,spw_cont
|
||
|
ld b,4
|
||
|
cp 2
|
||
|
jr z,spw_cont
|
||
|
ld b,8
|
||
|
cp 3
|
||
|
jr z,spw_cont
|
||
|
ld b,16
|
||
|
spw_cont:
|
||
|
ld a,b
|
||
|
ld (tankpw),a
|
||
|
ld hl,pwdot
|
||
|
ld (smlspr),hl
|
||
|
ld a,(lvldone)
|
||
|
bit 0,a
|
||
|
jr z,no_an_dot
|
||
|
ld a,28
|
||
|
jr an_dot
|
||
|
no_an_dot:
|
||
|
ld a,46
|
||
|
an_dot:
|
||
|
ld (y2),a
|
||
|
ld a,47
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 1,a
|
||
|
jr z,no_ma_dot
|
||
|
ld a,10
|
||
|
ld (y2),a
|
||
|
ld a,38
|
||
|
jr ma_dot
|
||
|
no_ma_dot:
|
||
|
ld a,28
|
||
|
ld (y2),a
|
||
|
ld a,65
|
||
|
ma_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 2,a
|
||
|
jr z,no_md_dot
|
||
|
ld a,46
|
||
|
ld (y2),a
|
||
|
ld a,65
|
||
|
jr md_dot
|
||
|
no_md_dot:
|
||
|
ld a,10
|
||
|
ld (y2),a
|
||
|
ld a,56
|
||
|
md_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 3,a
|
||
|
jr z,no_do_dot
|
||
|
ld a,37
|
||
|
ld (y2),a
|
||
|
ld a,47
|
||
|
jr do_dot
|
||
|
no_do_dot:
|
||
|
ld a,46
|
||
|
ld (y2),a
|
||
|
ld a,38
|
||
|
do_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 4,a
|
||
|
jr z,no_po_dot
|
||
|
ld a,37
|
||
|
ld (y2),a
|
||
|
ld a,29
|
||
|
jr po_dot
|
||
|
no_po_dot:
|
||
|
ld a,19
|
||
|
ld (y2),a
|
||
|
ld a,65
|
||
|
po_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 5,a
|
||
|
jr z,no_fr_dot
|
||
|
ld a,56
|
||
|
jr fr_dot
|
||
|
no_fr_dot:
|
||
|
ld a,29
|
||
|
fr_dot:
|
||
|
ld (x2),a
|
||
|
ld a,19
|
||
|
ld (y2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 5,a
|
||
|
jr z,no_se_dot
|
||
|
ld a,46
|
||
|
ld (y2),a
|
||
|
ld a,29
|
||
|
jr se_dot
|
||
|
no_se_dot:
|
||
|
ld a,28
|
||
|
ld (y2),a
|
||
|
ld a,56
|
||
|
se_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 6,a
|
||
|
jr z,no_sa_dot
|
||
|
ld a,38
|
||
|
jr sa_dot
|
||
|
no_sa_dot:
|
||
|
ld a,47
|
||
|
sa_dot:
|
||
|
ld (x2),a
|
||
|
ld a,19
|
||
|
ld (y2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 7,a
|
||
|
jr z,no_mi_dot
|
||
|
ld a,28
|
||
|
ld (y2),a
|
||
|
ld a,38
|
||
|
jr mi_dot
|
||
|
no_mi_dot:
|
||
|
ld a,37
|
||
|
ld (y2),a
|
||
|
ld a,56
|
||
|
mi_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
tank_dot:
|
||
|
ld a,(tankpw)
|
||
|
ld b,a
|
||
|
ld a,10
|
||
|
ld (y2),a
|
||
|
ld a,47
|
||
|
ld (x2),a
|
||
|
bit 0,b
|
||
|
jr nz,tank_dot_found
|
||
|
ld a,46
|
||
|
ld (y2),a
|
||
|
ld a,56
|
||
|
ld (x2),a
|
||
|
bit 1,b
|
||
|
jr nz,tank_dot_found
|
||
|
ld a,28
|
||
|
ld (y2),a
|
||
|
ld a,29
|
||
|
ld (x2),a
|
||
|
bit 2,b
|
||
|
jr nz,tank_dot_found
|
||
|
ld a,10
|
||
|
ld (y2),a
|
||
|
ld a,65
|
||
|
ld (x2),a
|
||
|
bit 3,b
|
||
|
jr nz,tank_dot_found
|
||
|
ld a,37
|
||
|
ld (y2),a
|
||
|
ld a,38
|
||
|
ld (x2),a
|
||
|
tank_dot_found:
|
||
|
call xor_8x8
|
||
|
call fastcopys
|
||
|
call pw_text
|
||
|
show_pw_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp kMode
|
||
|
ret z
|
||
|
cp kEnter
|
||
|
jr nz,show_pw_loop
|
||
|
ret
|
||
|
enter_pw:
|
||
|
xor a
|
||
|
ld (anpw),a
|
||
|
ld (mapw),a
|
||
|
ld (mdpw),a
|
||
|
ld (dopw),a
|
||
|
ld (popw),a
|
||
|
ld (frpw),a
|
||
|
ld (sepw),a
|
||
|
ld (sapw),a
|
||
|
ld (mipw),a
|
||
|
ld (tankpw),a
|
||
|
call draw_grid
|
||
|
ld hl,pwcurs
|
||
|
ld (smlspr),hl
|
||
|
ld a,10
|
||
|
ld (y2),a
|
||
|
ld a,29
|
||
|
ld (x2),a
|
||
|
ep_loop_new:
|
||
|
call xor_8x8
|
||
|
call fastcopys
|
||
|
call pw_text
|
||
|
call xor_8x8
|
||
|
ep_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp kLeft
|
||
|
jr z,ep_left
|
||
|
cp kRight
|
||
|
jr z,ep_right
|
||
|
cp kUp
|
||
|
jr z,ep_up
|
||
|
cp kDown
|
||
|
jr z,ep_down
|
||
|
cp k2nd
|
||
|
jr z,ep_dot
|
||
|
cp kEnter
|
||
|
jp z,check_pw
|
||
|
cp kMode
|
||
|
ret z
|
||
|
jr ep_loop
|
||
|
ep_left:
|
||
|
ld a,(x2)
|
||
|
cp 29
|
||
|
jr z,ep_horz
|
||
|
sub 9
|
||
|
ld (x2),a
|
||
|
jr ep_loop_new
|
||
|
ep_right:
|
||
|
ld a,(x2)
|
||
|
cp 65
|
||
|
jr z,ep_horz
|
||
|
add a,9
|
||
|
ld (x2),a
|
||
|
jr ep_loop_new
|
||
|
ep_horz:
|
||
|
ld b,a
|
||
|
ld a,94
|
||
|
sub b
|
||
|
ld (x2),a
|
||
|
jr ep_loop_new
|
||
|
ep_up:
|
||
|
ld a,(y2)
|
||
|
cp 10
|
||
|
jr z,ep_vert
|
||
|
sub 9
|
||
|
ld (y2),a
|
||
|
jr ep_loop_new
|
||
|
ep_down:
|
||
|
ld a,(y2)
|
||
|
cp 46
|
||
|
jr z,ep_vert
|
||
|
add a,9
|
||
|
ld (y2),a
|
||
|
jr ep_loop_new
|
||
|
ep_vert:
|
||
|
ld b,a
|
||
|
ld a,56
|
||
|
sub b
|
||
|
ld (y2),a
|
||
|
jr ep_loop_new
|
||
|
ep_dot:
|
||
|
ld hl,pwdot
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld hl,pwcurs
|
||
|
ld (smlspr),hl
|
||
|
ld a,(y2)
|
||
|
cp 10
|
||
|
jr z,rowa
|
||
|
cp 19
|
||
|
jr z,rowb
|
||
|
cp 28
|
||
|
jp z,rowc
|
||
|
cp 37
|
||
|
jp z,rowd
|
||
|
jp rowe
|
||
|
rowa:
|
||
|
ld a,(x2)
|
||
|
cp 29
|
||
|
jr z,rowa_col1
|
||
|
cp 38
|
||
|
jr z,rowa_col2
|
||
|
cp 47
|
||
|
jr z,rowa_col3
|
||
|
cp 56
|
||
|
jr z,rowa_col4
|
||
|
jr rowa_col5
|
||
|
rowa_col1:
|
||
|
ld a,(tankpw)
|
||
|
bit 5,a
|
||
|
set 5,a
|
||
|
jp z,tankpw_done
|
||
|
res 5,a
|
||
|
jp tankpw_done
|
||
|
rowa_col2:
|
||
|
ld a,(mapw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jr z,mapw_done
|
||
|
res 1,a
|
||
|
mapw_done:
|
||
|
ld (mapw),a
|
||
|
jp ep_loop_new
|
||
|
rowa_col3:
|
||
|
ld a,(tankpw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jp z,tankpw_done
|
||
|
res 0,a
|
||
|
jp tankpw_done
|
||
|
rowa_col4:
|
||
|
ld a,(mdpw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jr z,mdpw_done
|
||
|
res 0,a
|
||
|
mdpw_done:
|
||
|
ld (mdpw),a
|
||
|
jp ep_loop_new
|
||
|
rowa_col5:
|
||
|
ld a,(tankpw)
|
||
|
bit 3,a
|
||
|
set 3,a
|
||
|
jp z,tankpw_done
|
||
|
res 3,a
|
||
|
jp tankpw_done
|
||
|
rowb:
|
||
|
ld a,(x2)
|
||
|
cp 29
|
||
|
jr z,rowb_col1
|
||
|
cp 38
|
||
|
jr z,rowb_col2
|
||
|
cp 47
|
||
|
jr z,rowb_col3
|
||
|
cp 56
|
||
|
jr z,rowb_col4
|
||
|
jr rowb_col5
|
||
|
rowb_col1:
|
||
|
ld a,(frpw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jr z,frpw_done
|
||
|
res 0,a
|
||
|
frpw_done:
|
||
|
ld (frpw),a
|
||
|
jp ep_loop_new
|
||
|
rowb_col2:
|
||
|
ld a,(sapw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jr z,sapw_done
|
||
|
res 1,a
|
||
|
sapw_done:
|
||
|
ld (sapw),a
|
||
|
jp ep_loop_new
|
||
|
rowb_col3:
|
||
|
ld a,(sapw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jr z,sapw_done
|
||
|
res 0,a
|
||
|
jr sapw_done
|
||
|
rowb_col4:
|
||
|
ld a,(frpw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jr z,frpw_done
|
||
|
res 1,a
|
||
|
jr frpw_done
|
||
|
rowb_col5:
|
||
|
ld a,(popw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jr z,popw_done
|
||
|
res 0,a
|
||
|
popw_done:
|
||
|
ld (popw),a
|
||
|
jp ep_loop_new
|
||
|
rowc:
|
||
|
ld a,(x2)
|
||
|
cp 29
|
||
|
jr z,rowc_col1
|
||
|
cp 38
|
||
|
jr z,rowc_col2
|
||
|
cp 47
|
||
|
jr z,rowc_col3
|
||
|
cp 56
|
||
|
jr z,rowc_col4
|
||
|
jr rowc_col5
|
||
|
rowc_col1:
|
||
|
ld a,(tankpw)
|
||
|
bit 2,a
|
||
|
set 2,a
|
||
|
jr z,tankpw_done
|
||
|
res 2,a
|
||
|
tankpw_done:
|
||
|
ld (tankpw),a
|
||
|
jp ep_loop_new
|
||
|
rowc_col2:
|
||
|
ld a,(mipw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jr z,mipw_done
|
||
|
res 1,a
|
||
|
mipw_done:
|
||
|
ld (mipw),a
|
||
|
jp ep_loop_new
|
||
|
rowc_col3:
|
||
|
ld a,(anpw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jp z,anpw_done
|
||
|
res 1,a
|
||
|
jp anpw_done
|
||
|
rowc_col4:
|
||
|
ld a,(sepw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jp z,sepw_done
|
||
|
res 0,a
|
||
|
jp sepw_done
|
||
|
rowc_col5:
|
||
|
ld a,(mapw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jp z,mapw_done
|
||
|
res 0,a
|
||
|
jp mapw_done
|
||
|
rowd:
|
||
|
ld a,(x2)
|
||
|
cp 29
|
||
|
jr z,rowd_col1
|
||
|
cp 38
|
||
|
jr z,rowd_col2
|
||
|
cp 47
|
||
|
jr z,rowd_col3
|
||
|
cp 56
|
||
|
jr z,rowd_col4
|
||
|
jr rowd_col5
|
||
|
rowd_col1:
|
||
|
ld a,(popw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jp z,popw_done
|
||
|
res 1,a
|
||
|
jp popw_done
|
||
|
rowd_col2:
|
||
|
ld a,(tankpw)
|
||
|
bit 4,a
|
||
|
set 4,a
|
||
|
jr z,tankpw_done
|
||
|
res 4,a
|
||
|
jr tankpw_done
|
||
|
rowd_col3:
|
||
|
ld a,(dopw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jr z,dopw_done
|
||
|
res 1,a
|
||
|
dopw_done:
|
||
|
ld (dopw),a
|
||
|
jp ep_loop_new
|
||
|
rowd_col4:
|
||
|
ld a,(mipw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jr z,mipw_done
|
||
|
res 0,a
|
||
|
jp mipw_done
|
||
|
rowd_col5:
|
||
|
ld a,(tankpw)
|
||
|
bit 6,a
|
||
|
set 6,a
|
||
|
jp z,tankpw_done
|
||
|
res 6,a
|
||
|
jp tankpw_done
|
||
|
rowe:
|
||
|
ld a,(x2)
|
||
|
cp 29
|
||
|
jr z,rowe_col1
|
||
|
cp 38
|
||
|
jr z,rowe_col2
|
||
|
cp 47
|
||
|
jr z,rowe_col3
|
||
|
cp 56
|
||
|
jr z,rowe_col4
|
||
|
jr rowe_col5
|
||
|
rowe_col1:
|
||
|
ld a,(sepw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jr z,sepw_done
|
||
|
res 1,a
|
||
|
sepw_done:
|
||
|
ld (sepw),a
|
||
|
jp ep_loop_new
|
||
|
rowe_col2:
|
||
|
ld a,(dopw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jr z,dopw_done
|
||
|
res 0,a
|
||
|
jr dopw_done
|
||
|
rowe_col3:
|
||
|
ld a,(anpw)
|
||
|
bit 0,a
|
||
|
set 0,a
|
||
|
jr z,anpw_done
|
||
|
res 0,a
|
||
|
anpw_done:
|
||
|
ld (anpw),a
|
||
|
jp ep_loop_new
|
||
|
rowe_col4:
|
||
|
ld a,(tankpw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jp z,tankpw_done
|
||
|
res 1,a
|
||
|
jp tankpw_done
|
||
|
rowe_col5:
|
||
|
ld a,(mdpw)
|
||
|
bit 1,a
|
||
|
set 1,a
|
||
|
jp z,mdpw_done
|
||
|
res 1,a
|
||
|
jp mdpw_done
|
||
|
check_pw:
|
||
|
ld a,(anpw)
|
||
|
or a
|
||
|
jr z,pw_error
|
||
|
cp 3
|
||
|
jr z,pw_error
|
||
|
ld a,(mapw)
|
||
|
or a
|
||
|
jr z,pw_error
|
||
|
cp 3
|
||
|
jr z,pw_error
|
||
|
ld a,(mdpw)
|
||
|
or a
|
||
|
jr z,pw_error
|
||
|
cp 3
|
||
|
jr z,pw_error
|
||
|
ld a,(dopw)
|
||
|
or a
|
||
|
jr z,pw_error
|
||
|
cp 3
|
||
|
jr z,pw_error
|
||
|
ld a,(popw)
|
||
|
or a
|
||
|
jr z,pw_error
|
||
|
cp 3
|
||
|
jr z,pw_error
|
||
|
ld a,(frpw)
|
||
|
or a
|
||
|
jr z,pw_error
|
||
|
cp 3
|
||
|
jr z,pw_error
|
||
|
ld a,(sepw)
|
||
|
or a
|
||
|
jr z,pw_error
|
||
|
cp 3
|
||
|
jr z,pw_error
|
||
|
ld a,(sapw)
|
||
|
or a
|
||
|
jr z,pw_error
|
||
|
cp 3
|
||
|
jr z,pw_error
|
||
|
ld a,(mipw)
|
||
|
or a
|
||
|
jr z,pw_error
|
||
|
cp 3
|
||
|
jr z,pw_error
|
||
|
ld a,(tankpw)
|
||
|
ld b,0
|
||
|
cp 1
|
||
|
jp z,pw_good
|
||
|
inc b
|
||
|
cp 2
|
||
|
jp z,pw_good
|
||
|
inc b
|
||
|
cp 4
|
||
|
jp z,pw_good
|
||
|
inc b
|
||
|
cp 8
|
||
|
jp z,pw_good
|
||
|
inc b
|
||
|
cp 16
|
||
|
jp z,pw_good
|
||
|
pw_error:
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
ld hl,pw_error_lindat
|
||
|
call draw
|
||
|
call fastcopys
|
||
|
ld de,10*256+20
|
||
|
ld hl,pwerr
|
||
|
call setvputs
|
||
|
ld de,40*256+30
|
||
|
ld hl,pwtry
|
||
|
call setvputs
|
||
|
ld de,47*256+33
|
||
|
ld hl,yes
|
||
|
call setvputs
|
||
|
ld de,54*256+31
|
||
|
ld hl,no
|
||
|
call setvputs
|
||
|
pe_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp k2nd
|
||
|
jp z,enter_pw
|
||
|
cp kAlpha
|
||
|
ret z
|
||
|
cp kMode
|
||
|
ret z
|
||
|
jr pe_loop
|
||
|
pw_good:
|
||
|
ld a,b
|
||
|
ld (tanks),a
|
||
|
ld a,(lvldone)
|
||
|
ld b,a
|
||
|
ld a,(anpw)
|
||
|
bit 1,a
|
||
|
jr z,pg1
|
||
|
set 0,b
|
||
|
pg1:
|
||
|
ld a,(mapw)
|
||
|
bit 1,a
|
||
|
jr z,pg2
|
||
|
set 1,b
|
||
|
pg2:
|
||
|
ld a,(mdpw)
|
||
|
bit 1,a
|
||
|
jr z,pg3
|
||
|
set 2,b
|
||
|
pg3:
|
||
|
ld a,(dopw)
|
||
|
bit 1,a
|
||
|
jr z,pg4
|
||
|
set 3,b
|
||
|
pg4:
|
||
|
ld a,(popw)
|
||
|
bit 1,a
|
||
|
jr z,pg5
|
||
|
set 4,b
|
||
|
pg5:
|
||
|
ld a,(frpw)
|
||
|
bit 1,a
|
||
|
jr z,pg6
|
||
|
set 5,b
|
||
|
pg6:
|
||
|
ld a,(sapw)
|
||
|
bit 1,a
|
||
|
jr z,pg7
|
||
|
set 6,b
|
||
|
pg7:
|
||
|
ld a,(mipw)
|
||
|
bit 1,a
|
||
|
jr z,pg_done
|
||
|
set 7,b
|
||
|
pg_done:
|
||
|
ld a,b
|
||
|
ld (lvldone),a
|
||
|
ret
|
||
|
ship_init:
|
||
|
ld a,(bchk)
|
||
|
or a
|
||
|
ret z
|
||
|
ld hl,ship_init_lindat
|
||
|
call draw
|
||
|
ld a,56
|
||
|
ld (xb),a
|
||
|
ld a,16
|
||
|
ld (yb),a
|
||
|
ret
|
||
|
xor_laser:
|
||
|
ld hl,xor_laser_lindat
|
||
|
call draw
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
call xor_boss
|
||
|
call fastcopys
|
||
|
ld hl,xor_laser_lindat
|
||
|
call draw
|
||
|
call xor_char
|
||
|
call xor_boss
|
||
|
ret
|
||
|
wpn_fill:
|
||
|
ld a,28
|
||
|
ld (enp),a
|
||
|
ld (enan),a
|
||
|
ld (enma),a
|
||
|
ld (enmd),a
|
||
|
ld (endo),a
|
||
|
ld (ense),a
|
||
|
ld (enpo),a
|
||
|
ld (enfr),a
|
||
|
ld (ensa),a
|
||
|
ld (enmi),a
|
||
|
ld (enwpn),a
|
||
|
ret
|
||
|
draw_nrg:
|
||
|
ld a,(bchk)
|
||
|
or a
|
||
|
call nz,draw_bnrg
|
||
|
ld d,10
|
||
|
ld e,38
|
||
|
ld h,10
|
||
|
ld a,(enp)
|
||
|
ld b,a
|
||
|
ld a,37
|
||
|
sub b
|
||
|
ld l,a
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ld a,(wpn)
|
||
|
or a
|
||
|
ret z
|
||
|
ld d,12 ; draw weapon energy line
|
||
|
ld e,38
|
||
|
ld h,12
|
||
|
ld a,(enwpn)
|
||
|
ld b,a
|
||
|
ld a,37
|
||
|
sub b
|
||
|
ld l,a
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ret
|
||
|
draw_bnrg:
|
||
|
ld d,86
|
||
|
ld e,38
|
||
|
ld h,86
|
||
|
ld a,(enb)
|
||
|
ld b,a
|
||
|
ld a,37
|
||
|
sub b
|
||
|
ld l,a
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ret
|
||
|
check_ehitu:
|
||
|
ld a,(echk)
|
||
|
cp 3
|
||
|
ret z
|
||
|
ld a,(wx1)
|
||
|
ld d,a
|
||
|
ld a,(wy1)
|
||
|
ld e,a
|
||
|
ld a,(wchk1)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_white
|
||
|
ld a,c
|
||
|
ld (wchk1),a
|
||
|
ld a,(wx2)
|
||
|
ld d,a
|
||
|
ld a,(wy2)
|
||
|
ld e,a
|
||
|
ld a,(wchk2)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_white
|
||
|
ld a,c
|
||
|
ld (wchk2),a
|
||
|
ld a,(wx3)
|
||
|
ld d,a
|
||
|
ld a,(wy3)
|
||
|
ld e,a
|
||
|
ld a,(wchk3)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_white
|
||
|
ld a,c
|
||
|
ld (wchk3),a
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(xe)
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,(ye)
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,18
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,ehitu_nokill
|
||
|
xor a
|
||
|
ehitu_nokill:
|
||
|
ld (enp),a
|
||
|
ld a,1
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
check_bhitu:
|
||
|
ld a,(wx1)
|
||
|
ld d,a
|
||
|
ld a,(wy1)
|
||
|
ld e,a
|
||
|
ld a,(wchk1)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_whitb
|
||
|
ld a,c
|
||
|
ld (wchk1),a
|
||
|
ld a,(wx2)
|
||
|
ld d,a
|
||
|
ld a,(wy2)
|
||
|
ld e,a
|
||
|
ld a,(wchk2)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_whitb
|
||
|
ld a,c
|
||
|
ld (wchk2),a
|
||
|
ld a,(wx3)
|
||
|
ld d,a
|
||
|
ld a,(wy3)
|
||
|
ld e,a
|
||
|
ld a,(wchk3)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_whitb
|
||
|
ld a,c
|
||
|
ld (wchk3),a
|
||
|
ld a,(boss)
|
||
|
cp 5
|
||
|
jr z,check_shitu
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(xb)
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,(yb)
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,22
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 7
|
||
|
jr nc,bhitu_nokill
|
||
|
xor a
|
||
|
bhitu_nokill:
|
||
|
ld (enp),a
|
||
|
ld a,1
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
check_shitu:
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,28
|
||
|
cp b
|
||
|
ret nc
|
||
|
xor a
|
||
|
ld (enp),a
|
||
|
ld a,1
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
check_bwhitu:
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(bwx)
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,38
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 2
|
||
|
jr nc,bwhitu_nokill
|
||
|
xor a
|
||
|
bwhitu_nokill:
|
||
|
ld (enp),a
|
||
|
ld a,1
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
check_white:
|
||
|
ld a,(xe)
|
||
|
ld b,a
|
||
|
ld a,d
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ye)
|
||
|
ld b,a
|
||
|
ld a,e
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,10
|
||
|
cp b
|
||
|
ret c
|
||
|
ld c,0
|
||
|
ld a,(ene)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,white_nokill
|
||
|
xor a
|
||
|
white_nokill:
|
||
|
ld (ene),a
|
||
|
or a
|
||
|
ret nz
|
||
|
ld a,3
|
||
|
ld (echk),a
|
||
|
ret
|
||
|
check_whitb:
|
||
|
ld a,(boss)
|
||
|
cp 5
|
||
|
jr z,check_whits
|
||
|
ld a,(xb)
|
||
|
ld b,a
|
||
|
ld a,d
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(yb)
|
||
|
ld b,a
|
||
|
ld a,e
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld c,0
|
||
|
call dam7_or1
|
||
|
ld a,(enb)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,whitb_nokill
|
||
|
xor a
|
||
|
whitb_nokill:
|
||
|
ld (enb),a
|
||
|
ret nz
|
||
|
call won
|
||
|
ret
|
||
|
check_whits:
|
||
|
ld b,35
|
||
|
ld a,d
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld b,42
|
||
|
ld a,e
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,10
|
||
|
cp b
|
||
|
ret c
|
||
|
ld c,0
|
||
|
call dam7_or1
|
||
|
ld a,(enb)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,whits_nokill
|
||
|
xor a
|
||
|
whits_nokill:
|
||
|
ld (enb),a
|
||
|
or a
|
||
|
ret nz
|
||
|
call won
|
||
|
ret
|
||
|
dam7_or1:
|
||
|
ld a,(wpn)
|
||
|
or a
|
||
|
ret z
|
||
|
cp 5
|
||
|
ret z
|
||
|
cp 1
|
||
|
jr z,an_on_po
|
||
|
cp 2
|
||
|
jr z,ma_on_do
|
||
|
cp 3
|
||
|
jr z,md_on_sa
|
||
|
cp 4
|
||
|
jr z,do_on_fr
|
||
|
cp 6
|
||
|
jr z,po_on_md
|
||
|
cp 7
|
||
|
jr z,fr_on_an
|
||
|
cp 8
|
||
|
jr z,sa_on_mi
|
||
|
cp 9
|
||
|
jr z,mi_on_ma
|
||
|
ret
|
||
|
an_on_po:
|
||
|
ld a,(boss)
|
||
|
cp 5
|
||
|
jr z,damage7
|
||
|
cp 6
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
ma_on_do:
|
||
|
ld a,(boss)
|
||
|
or a
|
||
|
jr z,damage7
|
||
|
cp 4
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
md_on_sa:
|
||
|
ld a,(boss)
|
||
|
cp 8
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
do_on_fr:
|
||
|
ld a,(boss)
|
||
|
cp 7
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
po_on_md:
|
||
|
ld a,(boss)
|
||
|
cp 3
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
fr_on_an:
|
||
|
ld a,(boss)
|
||
|
cp 1
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
sa_on_mi:
|
||
|
ld a,(boss)
|
||
|
cp 9
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
mi_on_ma:
|
||
|
ld a,(boss)
|
||
|
cp 2
|
||
|
ret nz
|
||
|
damage7:
|
||
|
ld a,(enb)
|
||
|
or a
|
||
|
sub 6
|
||
|
jr nc,dam7_nokill
|
||
|
call won
|
||
|
xor a
|
||
|
dam7_nokill:
|
||
|
ld (enb),a
|
||
|
ret
|
||
|
thrown_back:
|
||
|
xor a
|
||
|
ld (hchk),a
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
or a
|
||
|
ld de,8
|
||
|
sbc hl,de
|
||
|
push hl
|
||
|
push hl
|
||
|
call CheckHorz
|
||
|
pop hl
|
||
|
call z,CheckHorz2
|
||
|
pop hl
|
||
|
call z,CheckHorz3
|
||
|
jr nz,thrown_short
|
||
|
ld a,(xmm)
|
||
|
sub 8
|
||
|
ld (xmm),a
|
||
|
ret
|
||
|
thrown_short:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
push hl
|
||
|
srl h
|
||
|
rr l
|
||
|
srl h
|
||
|
rr l
|
||
|
srl h
|
||
|
rr l ; divide x by 8
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl ; multiply x by 8
|
||
|
push hl
|
||
|
pop de
|
||
|
pop hl
|
||
|
or a
|
||
|
sbc hl,de
|
||
|
push hl
|
||
|
ld hl,(xmm)
|
||
|
pop de
|
||
|
or a
|
||
|
sbc hl,de
|
||
|
ld (xmm),hl
|
||
|
ret
|
||
|
draw_text:
|
||
|
;hl = pointer to text info
|
||
|
ld a,(hl)
|
||
|
ld e,a
|
||
|
inc hl
|
||
|
push de
|
||
|
push hl
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
ld a,1
|
||
|
pop hl
|
||
|
pop de
|
||
|
draw_txt_loop:
|
||
|
push af
|
||
|
push de
|
||
|
push hl
|
||
|
call centertext
|
||
|
pop hl
|
||
|
pop de
|
||
|
pop af
|
||
|
add a,6
|
||
|
cp 59
|
||
|
call nc,reseta_draw
|
||
|
push af
|
||
|
ld a,$00
|
||
|
ld b,255
|
||
|
cpir
|
||
|
pop af
|
||
|
dec e
|
||
|
jr nz,draw_txt_loop
|
||
|
call clrwait
|
||
|
ret
|
||
|
|
||
|
reseta_draw:
|
||
|
push af
|
||
|
push de
|
||
|
push hl
|
||
|
dec e
|
||
|
call nz,clrwait
|
||
|
inc e
|
||
|
pop hl
|
||
|
pop de
|
||
|
pop af
|
||
|
ld a,1
|
||
|
ret
|
||
|
clrwait:
|
||
|
call wait
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
ret
|
||
|
wait:
|
||
|
bcall(_getcsc)
|
||
|
or a
|
||
|
jr z,wait
|
||
|
ret
|
||
|
quit_force:
|
||
|
|
||
|
draw:
|
||
|
push af
|
||
|
push bc
|
||
|
push de
|
||
|
ld a,(hl)
|
||
|
ld b,a
|
||
|
inc hl
|
||
|
ld a,(hl)
|
||
|
inc hl
|
||
|
drawloop:
|
||
|
;hl = pointer to line data
|
||
|
;a = draw mode (0=off 1=on 2=xor 3=pattern)
|
||
|
;b = number of lines
|
||
|
push bc
|
||
|
ld c,(hl)
|
||
|
inc hl
|
||
|
ld b,(hl)
|
||
|
inc hl
|
||
|
ld e,(hl)
|
||
|
inc hl
|
||
|
ld d,(hl)
|
||
|
inc hl
|
||
|
push af
|
||
|
push hl
|
||
|
push bc
|
||
|
push de
|
||
|
pop de
|
||
|
pop hl
|
||
|
call fastline
|
||
|
pop hl
|
||
|
pop af
|
||
|
pop bc
|
||
|
djnz drawloop
|
||
|
pop de
|
||
|
pop bc
|
||
|
pop af
|
||
|
ret
|
||
|
|
||
|
Description: .db "Mario Demo 83+",0
|
||
|
prog_start:
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
xor a ; no levels completed
|
||
|
ld (lvldone),a
|
||
|
ld (tanks),a ; 0 energy tanks
|
||
|
inc a
|
||
|
ld (tankpw),a ; 0 energy tanks (for password system)
|
||
|
inc a
|
||
|
inc a
|
||
|
ld (lives),a ; 3 lives
|
||
|
ld a,17
|
||
|
ld (x2),a
|
||
|
ld a,43
|
||
|
ld (y2),a
|
||
|
ld hl,pwdot
|
||
|
ld (smlspr),hl
|
||
|
ld a,(y2)
|
||
|
cp 43
|
||
|
jr z,cb_init
|
||
|
cp kMode ; exit game if MODE was pressed on enter password screen
|
||
|
ret z
|
||
|
cb_init:
|
||
|
ld a,33
|
||
|
ld (x2),a
|
||
|
ld a,22
|
||
|
ld (y2),a
|
||
|
bcall(_clrlcdfull)
|
||
|
boss_loop:
|
||
|
call xor_corners
|
||
|
call fastcopys
|
||
|
call xor_corners
|
||
|
jr find_boss
|
||
|
bcall(_getcsc) ; clear the keybuffer
|
||
|
bcall(_grbufclr)
|
||
|
bcall(_clrlcdfull)
|
||
|
ret
|
||
|
find_boss:
|
||
|
ld a,(y2)
|
||
|
cp 1
|
||
|
jr z,row1
|
||
|
cp 22
|
||
|
jr z,row2
|
||
|
ld a,7
|
||
|
jr found_row
|
||
|
row2:
|
||
|
ld a,4
|
||
|
jr found_row
|
||
|
row1:
|
||
|
ld a,1
|
||
|
found_row:
|
||
|
ld (boss),a
|
||
|
ld a,(x2)
|
||
|
cp 64
|
||
|
jr z,add2
|
||
|
cp 33
|
||
|
jr nz,add0
|
||
|
ld a,(boss)
|
||
|
inc a
|
||
|
jr add_done
|
||
|
add0:
|
||
|
ld a,(boss)
|
||
|
jr add_done
|
||
|
add2:
|
||
|
ld a,(boss)
|
||
|
add a,2
|
||
|
add_done:
|
||
|
ld (boss),a
|
||
|
ld a,44
|
||
|
ld (xb),a
|
||
|
ld a,27
|
||
|
ld (yb),a
|
||
|
ld a,(boss)
|
||
|
cp 1
|
||
|
jr z,an_init
|
||
|
an_init:
|
||
|
ld a,(lvldone)
|
||
|
bit 0,a
|
||
|
jp c,boss_loop
|
||
|
ld hl,ansl
|
||
|
call disp_boss
|
||
|
ld hl,wpan
|
||
|
ld (bwspr),hl
|
||
|
ld a,54
|
||
|
ld hl,a_n
|
||
|
call centertext
|
||
|
ld hl,lvlan
|
||
|
intro_done:
|
||
|
ld (curlvl),hl ; remember the start of the level
|
||
|
ld (remlvl),hl
|
||
|
call delay
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
call wpn_fill
|
||
|
part1_init:
|
||
|
call init_vars
|
||
|
ld a,44 ; initialize some variables
|
||
|
ld (ymm),a
|
||
|
xor a
|
||
|
ld (jchk),a
|
||
|
ld (bchk),a
|
||
|
ld (wpn),a
|
||
|
inc a
|
||
|
ld (dir),a
|
||
|
ld (schk),a
|
||
|
ld hl,wpp
|
||
|
ld (wpnspr),hl
|
||
|
call ShowLevel
|
||
|
call main_loop
|
||
|
bcall(_getcsc) ; clear the keybuffer
|
||
|
bcall(_grbufclr)
|
||
|
bcall(_clrlcdfull)
|
||
|
ld a,(death) ; check if died
|
||
|
or a
|
||
|
jp nz,lost_life
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
ret z ; exit loop if level has not been completed
|
||
|
part2_init:
|
||
|
ld hl,lvlb1
|
||
|
xor a
|
||
|
ld (bchk),a
|
||
|
call init_lvlb
|
||
|
ld a,(death) ; check if died
|
||
|
or a
|
||
|
jp nz,lost_life
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
ret z ; exit loop if level has not been completed
|
||
|
xor a ; initialize boss variables
|
||
|
ld (bdir),a
|
||
|
ld (bjchk),a
|
||
|
inc a
|
||
|
ld (bchk),a
|
||
|
ld a,28
|
||
|
ld (enb),a
|
||
|
ld a,44
|
||
|
ld (yb),a
|
||
|
ld a,76
|
||
|
ld (xb),a
|
||
|
ld hl,lvlb2
|
||
|
call init_lvlb
|
||
|
ld a,(death) ; check if died
|
||
|
or a
|
||
|
jp nz,lost_life
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
ret z ; exit game if level has not been completed
|
||
|
ld a,(lvldone)
|
||
|
ld b,a
|
||
|
ld a,(boss)
|
||
|
cp 1
|
||
|
jr z,set_bit0
|
||
|
set 7,b
|
||
|
jr set_bit_done
|
||
|
set_bit6:
|
||
|
set 6,b
|
||
|
jr set_bit_done
|
||
|
set_bit5:
|
||
|
set 5,b
|
||
|
jr set_bit_done
|
||
|
set_bit4:
|
||
|
set 4,b
|
||
|
jr set_bit_done
|
||
|
set_bit3:
|
||
|
set 3,b
|
||
|
jr set_bit_done
|
||
|
set_bit2:
|
||
|
set 2,b
|
||
|
jr set_bit_done
|
||
|
set_bit1:
|
||
|
set 1,b
|
||
|
jr set_bit_done
|
||
|
set_bit0:
|
||
|
set 0,b
|
||
|
set_bit_done:
|
||
|
ld a,b
|
||
|
ld (lvldone),a
|
||
|
jp cb_init
|
||
|
lost_life:
|
||
|
call wpn_fill
|
||
|
ld a,(lives) ; go to game over screen if all lives lost
|
||
|
or a
|
||
|
jr z,game_over
|
||
|
ld a,(schk)
|
||
|
or a
|
||
|
jp z,part2_init
|
||
|
jp part1_init
|
||
|
game_over:
|
||
|
cp kMode ; exit if MODE was pressed at show password screen
|
||
|
ret z
|
||
|
ld a,3
|
||
|
ld (lives),a
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
call draw
|
||
|
call fastcopys
|
||
|
ld de,18*256+31
|
||
|
ld hl,gover
|
||
|
call setvputs
|
||
|
ld de,25*256+25
|
||
|
ld hl,cont
|
||
|
call setvputs
|
||
|
ld de,32*256+14
|
||
|
ld hl,stgsel
|
||
|
call setvputs
|
||
|
ld de,39*256+31
|
||
|
ld hl,endgame
|
||
|
call setvputs
|
||
|
bcall(_grbufclr)
|
||
|
go_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp k2nd
|
||
|
jr z,go_cont
|
||
|
cp kMode
|
||
|
ret z
|
||
|
jr go_loop
|
||
|
go_cont:
|
||
|
ld hl,(remlvl)
|
||
|
ld (curlvl),hl
|
||
|
jp part1_init
|
||
|
final_boss:
|
||
|
xor a
|
||
|
ld (boss),a ;select boss 0
|
||
|
ld (win),a ;you haven't won
|
||
|
call main_loop ;call the main loop
|
||
|
ld a,(death) ;check if you died
|
||
|
or a
|
||
|
jp nz,lost_life
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
ret z ; exit game if level has not been completed
|
||
|
ending:
|
||
|
ld hl,endingtext
|
||
|
call draw_text
|
||
|
ld hl,creditext
|
||
|
call draw_text
|
||
|
ld a,11
|
||
|
ld a,28
|
||
|
ld hl,and_inf
|
||
|
call centertext
|
||
|
call clrwait
|
||
|
ret
|
||
|
init_lvlb:
|
||
|
ld (curlvl),hl
|
||
|
call init_vars
|
||
|
ld (schk),a
|
||
|
ld (bcount),a
|
||
|
call ShowLevel
|
||
|
call main_loop
|
||
|
ld a,(win) ; see if you defeated TI's spaceship
|
||
|
cp 2
|
||
|
jr z,ship_dead
|
||
|
bcall(_getcsc) ; clear the keybuffer
|
||
|
bcall(_grbufclr)
|
||
|
bcall(_clrlcdfull)
|
||
|
ret
|
||
|
init_vars:
|
||
|
ld hl,0
|
||
|
ld (xscr),hl
|
||
|
ld (tempscr),hl
|
||
|
ld hl,8 ; initialize some variables
|
||
|
ld (xmm),hl
|
||
|
xor a
|
||
|
ld (wchk),a
|
||
|
ld (wchk1),a
|
||
|
ld (wchk2),a
|
||
|
ld (wchk3),a
|
||
|
ld (win),a
|
||
|
ld (death),a
|
||
|
ld (feet),a
|
||
|
ld (item),a
|
||
|
ld (echk),a
|
||
|
ld (bwchk),a
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
ship_dead:
|
||
|
ld a,28
|
||
|
ld (enb),a
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ld b,0 ; erase ship
|
||
|
call ship_init
|
||
|
ti_fall: ; TI falls to the bottom of the screen
|
||
|
ld a,(yb)
|
||
|
inc a
|
||
|
ld (yb),a
|
||
|
call xor_boss
|
||
|
call fastcopys
|
||
|
call xor_boss
|
||
|
ld a,(yb)
|
||
|
cp 44
|
||
|
jr nz,ti_fall
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ret
|
||
|
main_loop:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld a,(ymm)
|
||
|
add a,4
|
||
|
push hl
|
||
|
push af
|
||
|
call GetBlock
|
||
|
pop af
|
||
|
pop hl
|
||
|
ld de,8
|
||
|
add hl,de
|
||
|
call GetBlock
|
||
|
call ShowLevel
|
||
|
call check_spr ; figure out which Mega Man sprite to use
|
||
|
call xor_char ; draw it
|
||
|
call fastcopys ;copy everything to the buffer
|
||
|
call xor_char ;erase the Megaman sprite
|
||
|
ld a,(echk) ;check for enemy and erase as necessary
|
||
|
bcall(_grbufclr)
|
||
|
call find_spr
|
||
|
ld a,$FD ;check ENTER
|
||
|
out (1),a
|
||
|
in a,(1)
|
||
|
bit 0,a
|
||
|
call z,pause
|
||
|
ld a,$FE ;check arrow keys
|
||
|
out (1),a
|
||
|
in a,(1)
|
||
|
bit 1,a
|
||
|
call z,move_left
|
||
|
bit 2,a
|
||
|
call z,move_right
|
||
|
ld a,$BF ;check other keys
|
||
|
out (1),a
|
||
|
in a,(1)
|
||
|
bit 5,a
|
||
|
jr jump_button_down
|
||
|
main2:
|
||
|
bit 6,a
|
||
|
ret z ;exit loop is MODE has been pressed
|
||
|
ld a,(death)
|
||
|
or a
|
||
|
ret nz ;exit loop if dead
|
||
|
ld a,(win)
|
||
|
or a
|
||
|
jp z,main_loop ;exit loop if level completed
|
||
|
ret
|
||
|
jchk_now_2: ; make sure you can't jump
|
||
|
push af
|
||
|
ld a,2
|
||
|
ld (jchk),a
|
||
|
pop af
|
||
|
ret
|
||
|
jump_button_down:
|
||
|
push af
|
||
|
ld a,1
|
||
|
ld (maxjh),a
|
||
|
call z,jump
|
||
|
call nz,jchk_now_2
|
||
|
call fall
|
||
|
pop af
|
||
|
jr main2
|
||
|
move_right:
|
||
|
ld a,(feet)
|
||
|
and $02
|
||
|
ld hl,mmrr2
|
||
|
jr nz,rr2_spr
|
||
|
ld hl,mmrr
|
||
|
rr2_spr:
|
||
|
ld (curpic),hl
|
||
|
ld a,(xmm)
|
||
|
cp 80
|
||
|
call z,won
|
||
|
call CheckRight
|
||
|
call z,CheckRight2
|
||
|
call z,CheckRight3
|
||
|
jr nz,no_right
|
||
|
ld a,(xmm)
|
||
|
cp 44
|
||
|
jr nz,no_scroll
|
||
|
ld a,(xscr)
|
||
|
cp 68
|
||
|
jr z,no_scroll
|
||
|
ld a,(schk)
|
||
|
or a
|
||
|
jr z,no_scroll
|
||
|
call scroll
|
||
|
jr no_right
|
||
|
no_scroll:
|
||
|
ld hl,(xmm)
|
||
|
inc hl
|
||
|
inc hl
|
||
|
ld (xmm),hl
|
||
|
no_right:
|
||
|
ld a,(dir)
|
||
|
or a
|
||
|
call z,change_right
|
||
|
ret
|
||
|
change_right:
|
||
|
ld a,1
|
||
|
ld (dir),a
|
||
|
ret
|
||
|
move_left:
|
||
|
push af
|
||
|
ld a,(feet)
|
||
|
and $02
|
||
|
ld hl,mmrl2
|
||
|
jr nz,rl2_spr
|
||
|
ld hl,mmrl
|
||
|
rl2_spr:
|
||
|
ld (curpic),hl
|
||
|
ld a,(xmm)
|
||
|
or a
|
||
|
jr z,no_left
|
||
|
call CheckLeft
|
||
|
call z,CheckLeft2
|
||
|
call z,CheckLeft3
|
||
|
jr nz,no_left
|
||
|
call change_left
|
||
|
ld hl,(xmm)
|
||
|
dec hl
|
||
|
dec hl
|
||
|
ld (xmm),hl
|
||
|
no_left:
|
||
|
ld a,(dir)
|
||
|
or a
|
||
|
call nz,change_left
|
||
|
pop af
|
||
|
ret
|
||
|
change_left:
|
||
|
xor a
|
||
|
ld (dir),a
|
||
|
ret
|
||
|
CheckRight:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld de,8
|
||
|
add hl,de
|
||
|
jr CheckHorz
|
||
|
CheckLeft:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
dec hl
|
||
|
CheckHorz:
|
||
|
ld a,(ymm)
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
CheckRight2:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld de,8
|
||
|
add hl,de
|
||
|
jr CheckHorz2
|
||
|
CheckLeft2:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
dec hl
|
||
|
CheckHorz2:
|
||
|
ld a,(ymm)
|
||
|
add a,11
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
CheckRight3:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld de,8
|
||
|
add hl,de
|
||
|
jr CheckHorz3
|
||
|
CheckLeft3:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
dec hl
|
||
|
CheckHorz3:
|
||
|
ld a,(ymm)
|
||
|
add a,6
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
pause:
|
||
|
call tiny_delay
|
||
|
pause_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp kMode
|
||
|
ret z
|
||
|
cp kEnter
|
||
|
jr nz,pause_loop
|
||
|
call tiny_delay
|
||
|
ret
|
||
|
GetBlock: ; Gets the block at (HL,A) -> A. HL = addr, B,C = coord
|
||
|
srl h
|
||
|
rr l
|
||
|
srl h
|
||
|
rr l
|
||
|
srl h
|
||
|
rr l ; Divide X with 8
|
||
|
ld b,l
|
||
|
cp 64
|
||
|
jr c,OnScreen
|
||
|
xor a
|
||
|
OnScreen:
|
||
|
srl a
|
||
|
srl a
|
||
|
srl a ; Divide Y with 8
|
||
|
ld c,a
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
ld d,0
|
||
|
ld e,a
|
||
|
add hl,de ; HL = x*8+y
|
||
|
ld de,(curlvl)
|
||
|
add hl,de ; Add HL with the pointer to the level data
|
||
|
ld a,(hl)
|
||
|
ret
|
||
|
CheckTile:
|
||
|
or a
|
||
|
ret z
|
||
|
cp 8
|
||
|
ret c
|
||
|
xor a
|
||
|
ret
|
||
|
jump:
|
||
|
push af
|
||
|
ld a,(jchk)
|
||
|
cp 2
|
||
|
jr z,no_jump
|
||
|
or a
|
||
|
jr nz,jump_up
|
||
|
ld a,1
|
||
|
ld (jchk),a
|
||
|
ld a,(ymm)
|
||
|
sub 16
|
||
|
jr nc,jrem_not0
|
||
|
ld a,1
|
||
|
jrem_not0:
|
||
|
ld (jrem),a
|
||
|
jump_up:
|
||
|
ld a,(jrem)
|
||
|
ld b,a
|
||
|
ld a,(ymm)
|
||
|
cp b
|
||
|
jr c,end_jump
|
||
|
call CheckUp
|
||
|
call z,CheckUp2
|
||
|
jr nz,end_jump
|
||
|
ld a,(ymm)
|
||
|
dec a
|
||
|
dec a
|
||
|
dec a
|
||
|
dec a
|
||
|
ld (ymm),a
|
||
|
jr no_jump
|
||
|
end_jump:
|
||
|
ld a,2
|
||
|
ld (jchk),a
|
||
|
no_jump:
|
||
|
pop af
|
||
|
ret
|
||
|
fall:
|
||
|
push af
|
||
|
ld a,(jchk)
|
||
|
cp 1
|
||
|
jr z,no_fall
|
||
|
call CheckDown
|
||
|
call z,CheckDown2
|
||
|
jr nz,end_fall
|
||
|
ld a,(ymm)
|
||
|
inc a
|
||
|
inc a
|
||
|
inc a
|
||
|
inc a
|
||
|
ld (ymm),a
|
||
|
cp 52
|
||
|
call z,die
|
||
|
jr no_fall
|
||
|
end_fall:
|
||
|
xor a
|
||
|
ld (jchk),a
|
||
|
no_fall:
|
||
|
pop af
|
||
|
ret
|
||
|
CheckUp:
|
||
|
ld a,(ymm)
|
||
|
dec a
|
||
|
jr CheckVert
|
||
|
CheckDown:
|
||
|
ld a,(ymm)
|
||
|
add a,12
|
||
|
CheckVert:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
CheckUp2:
|
||
|
ld a,(ymm)
|
||
|
dec a
|
||
|
jr CheckVert2
|
||
|
CheckDown2:
|
||
|
ld a,(ymm)
|
||
|
add a,12
|
||
|
CheckVert2:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
ld de,7
|
||
|
add hl,de
|
||
|
call GetBlock
|
||
|
call CheckTile
|
||
|
ret
|
||
|
inc_wchk: ; lets you shoot again
|
||
|
inc a
|
||
|
cp 8
|
||
|
jr nz,keep_wchk
|
||
|
xor a
|
||
|
keep_wchk:
|
||
|
ld (wchk),a
|
||
|
ret
|
||
|
die:
|
||
|
call short_delay
|
||
|
ld a,(lives)
|
||
|
dec a
|
||
|
ld (lives),a
|
||
|
ld a,1
|
||
|
ld (death),a
|
||
|
ret
|
||
|
won:
|
||
|
ld a,1
|
||
|
ld (win),a
|
||
|
ld a,(bchk) ; check for boss
|
||
|
or a
|
||
|
ret z
|
||
|
ld a,(boss) ; see if that boss was the spaceship
|
||
|
cp 5
|
||
|
ret nz
|
||
|
ld a,2 ; if so, set win=2
|
||
|
ld (win),a
|
||
|
ret
|
||
|
scroll:
|
||
|
bcall(_grbufclr)
|
||
|
ld a,(tempscr)
|
||
|
inc a
|
||
|
inc a
|
||
|
cp 8
|
||
|
jr nz,scroll_cont
|
||
|
ld a,(xscr)
|
||
|
inc a
|
||
|
ld (xscr),a
|
||
|
xor a
|
||
|
scroll_cont:
|
||
|
ld (tempscr),a
|
||
|
ld a,(echk)
|
||
|
or a
|
||
|
call nz,next_en
|
||
|
ld a,(echk)
|
||
|
or a
|
||
|
ret z
|
||
|
cp 3
|
||
|
ret z
|
||
|
ld a,(xe) ; decrease x-coord of enemy
|
||
|
dec a
|
||
|
ld (xe),a
|
||
|
or a
|
||
|
call z,en_dead
|
||
|
ret
|
||
|
ShowLevel:
|
||
|
ld hl,(xscr)
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
push hl
|
||
|
pop de
|
||
|
ld hl,(curlvl)
|
||
|
add hl,de
|
||
|
ld bc,0
|
||
|
RepShowLevel: ; displays the current full screen of the level
|
||
|
ld a,(hl)
|
||
|
cp 5
|
||
|
call nc,item_init
|
||
|
inc hl
|
||
|
push hl
|
||
|
ld h,0
|
||
|
ld l,a
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
ld de,lvlspr
|
||
|
add hl,de
|
||
|
push bc
|
||
|
ld a,(tempscr)
|
||
|
ld d,a
|
||
|
ld a,b
|
||
|
sub d
|
||
|
jr c,skip_8x8
|
||
|
ld (x2),a
|
||
|
ld a,c
|
||
|
ld (y2),a
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
skip_8x8:
|
||
|
pop bc
|
||
|
pop hl
|
||
|
ld a,c
|
||
|
add a,8
|
||
|
ld c,a
|
||
|
cp 64
|
||
|
jr nz,RepShowLevel
|
||
|
ld c,0
|
||
|
ld a,b
|
||
|
add a,8
|
||
|
ld b,a
|
||
|
cp 96
|
||
|
jr nz,RepShowLevel
|
||
|
ret
|
||
|
item_init:
|
||
|
ld d,a
|
||
|
cp 8
|
||
|
jr nc,no_en_init
|
||
|
ld a,(item)
|
||
|
cp 2
|
||
|
jr z,no_item_init
|
||
|
ld a,1
|
||
|
ld (item),a
|
||
|
ld a,d
|
||
|
ret
|
||
|
no_item_init:
|
||
|
xor a ; replace item sprite with blank sprite
|
||
|
ret
|
||
|
t_init:
|
||
|
i_init:
|
||
|
no_en_init:
|
||
|
xor a ; replace enemy sprite with blank sprite
|
||
|
ret
|
||
|
load_x: ; loads x location (input as hl) into hl, accounting for scrolling
|
||
|
push hl
|
||
|
ld hl,(xscr)
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
pop de
|
||
|
add hl,de
|
||
|
push hl
|
||
|
ld hl,(tempscr)
|
||
|
pop de
|
||
|
add hl,de
|
||
|
ret
|
||
|
sub_screen:
|
||
|
push af
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
call tiny_delay
|
||
|
xor a
|
||
|
ld (wchk1),a
|
||
|
ld (wchk2),a
|
||
|
ld (wchk3),a
|
||
|
ld a,(wpn)
|
||
|
or a
|
||
|
jr z,ss_cont
|
||
|
cp 1
|
||
|
jr z,en_an
|
||
|
cp 2
|
||
|
jr z,en_ma
|
||
|
cp 3
|
||
|
jr z,en_md
|
||
|
cp 4
|
||
|
jr z,en_do
|
||
|
cp 5
|
||
|
jr z,en_se
|
||
|
cp 6
|
||
|
jr z,en_po
|
||
|
cp 7
|
||
|
jr z,en_fr
|
||
|
cp 8
|
||
|
jr z,en_sa
|
||
|
cp 9
|
||
|
jr z,en_mi
|
||
|
en_an:
|
||
|
ld a,(enwpn)
|
||
|
ld (enan),a
|
||
|
jr ss_cont
|
||
|
en_ma:
|
||
|
ld a,(enwpn)
|
||
|
ld (enma),a
|
||
|
jr ss_cont
|
||
|
en_md:
|
||
|
ld a,(enwpn)
|
||
|
ld (enmd),a
|
||
|
jr ss_cont
|
||
|
en_do:
|
||
|
ld a,(enwpn)
|
||
|
ld (endo),a
|
||
|
jr ss_cont
|
||
|
en_se:
|
||
|
ld a,(enwpn)
|
||
|
ld (ense),a
|
||
|
jr ss_cont
|
||
|
en_po:
|
||
|
ld a,(enwpn)
|
||
|
ld (enpo),a
|
||
|
jr ss_cont
|
||
|
en_fr:
|
||
|
ld a,(enwpn)
|
||
|
ld (enfr),a
|
||
|
jr ss_cont
|
||
|
en_sa:
|
||
|
ld a,(enwpn)
|
||
|
ld (ensa),a
|
||
|
jr ss_cont
|
||
|
en_mi:
|
||
|
ld a,(enwpn)
|
||
|
ld (enmi),a
|
||
|
ss_cont:
|
||
|
ld a,28
|
||
|
ld (x2),a
|
||
|
ld a,53
|
||
|
ld (y2),a
|
||
|
ld a,55
|
||
|
ld (x2),a
|
||
|
xor a
|
||
|
ld (x2),a
|
||
|
inc a
|
||
|
ld (y2),a
|
||
|
ld hl,pwdot
|
||
|
ld (smlspr),hl
|
||
|
ss_loop_new:
|
||
|
call xor_8x8
|
||
|
call fastcopys
|
||
|
ld a,(lvldone)
|
||
|
bit 0,a
|
||
|
jr z,ss_line1
|
||
|
ld d,16
|
||
|
ld e,15
|
||
|
push af
|
||
|
ld a,(enan)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,15
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line1:
|
||
|
bit 1,a
|
||
|
jr z,ss_line2
|
||
|
ld d,16
|
||
|
ld e,25
|
||
|
push af
|
||
|
ld a,(enma)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,25
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line2:
|
||
|
bit 2,a
|
||
|
jr z,ss_line3
|
||
|
ld d,16
|
||
|
ld e,35
|
||
|
push af
|
||
|
ld a,(enmd)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,35
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line3:
|
||
|
bit 3,a
|
||
|
jr z,ss_line4
|
||
|
ld d,16
|
||
|
ld e,45
|
||
|
push af
|
||
|
ld a,(endo)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,45
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line4:
|
||
|
bit 4,a
|
||
|
jr z,ss_line5
|
||
|
ld d,63
|
||
|
ld e,15
|
||
|
push af
|
||
|
ld a,(enpo)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,15
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line5:
|
||
|
bit 5,a
|
||
|
jr z,ss_line6
|
||
|
ld d,63
|
||
|
ld e,5
|
||
|
push af
|
||
|
ld a,(ense)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,5
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ld d,63
|
||
|
ld e,25
|
||
|
ld a,(enfr)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,25
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line6:
|
||
|
bit 6,a
|
||
|
jr z,ss_line7
|
||
|
ld d,63
|
||
|
ld e,35
|
||
|
push af
|
||
|
ld a,(ensa)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,35
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
pop af
|
||
|
ss_line7:
|
||
|
bit 7,a
|
||
|
jr z,ss_line_done
|
||
|
ld d,63
|
||
|
ld e,45
|
||
|
ld a,(enmi)
|
||
|
add a,64
|
||
|
ld h,a
|
||
|
ld l,45
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ss_line_done:
|
||
|
ld d,16
|
||
|
ld e,5
|
||
|
ld a,(enp)
|
||
|
add a,17
|
||
|
ld h,a
|
||
|
ld l,5
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
call fastcopys
|
||
|
ld a,(lvldone)
|
||
|
bit 0,a
|
||
|
jr z,ss_bit1
|
||
|
ld de,12*256+7
|
||
|
ld hl,an
|
||
|
call setvputs
|
||
|
ss_bit1:
|
||
|
bit 1,a
|
||
|
jr z,ss_bit2
|
||
|
ld de,22*256+7
|
||
|
ld hl,ma
|
||
|
call setvputs
|
||
|
ss_bit2:
|
||
|
bit 2,a
|
||
|
jr z,ss_bit3
|
||
|
ld de,32*256+7
|
||
|
ld hl,md
|
||
|
call setvputs
|
||
|
ss_bit3:
|
||
|
bit 3,a
|
||
|
jr z,ss_bit4
|
||
|
ld de,42*256+7
|
||
|
ld hl,do
|
||
|
call setvputs
|
||
|
ss_bit4:
|
||
|
bit 4,a
|
||
|
jr z,ss_bit5
|
||
|
ld de,12*256+54
|
||
|
ld hl,po
|
||
|
call setvputs
|
||
|
ss_bit5:
|
||
|
bit 5,a
|
||
|
jr z,ss_bit6
|
||
|
ld de,22*256+54
|
||
|
ld hl,fr
|
||
|
call setvputs
|
||
|
ld de,2*256+54
|
||
|
ld hl,se
|
||
|
call setvputs
|
||
|
ss_bit6:
|
||
|
bit 6,a
|
||
|
jr z,ss_bit7
|
||
|
ld de,32*256+54
|
||
|
ld hl,sa
|
||
|
call setvputs
|
||
|
ss_bit7:
|
||
|
bit 7,a
|
||
|
jr z,ss_loop_init
|
||
|
ld de,42*256+54
|
||
|
ld hl,mi
|
||
|
call setvputs
|
||
|
ss_loop_init:
|
||
|
ld de,2*256+7
|
||
|
ld hl,p
|
||
|
call setvputs
|
||
|
ld a,(tanks)
|
||
|
bcall(_setxxop1
|
||
|
ld hl,54*256+40
|
||
|
ld (pencol),hl
|
||
|
ld a,1
|
||
|
bcall(_dispop1a)
|
||
|
ld a,(lives)
|
||
|
bcall(_setxxop1)
|
||
|
ld hl,54*256+67
|
||
|
ld (pencol),hl
|
||
|
ld a,1
|
||
|
bcall(_dispop1a)
|
||
|
call xor_8x8
|
||
|
ss_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp kUp
|
||
|
jp z,ss_up
|
||
|
cp kDown
|
||
|
jp z,ss_down
|
||
|
cp kLeft
|
||
|
jp z,ss_horz
|
||
|
cp kRight
|
||
|
jp z,ss_horz
|
||
|
cp k2nd
|
||
|
jp z,ss_tank
|
||
|
cp kMode
|
||
|
jp z,ss_mode
|
||
|
cp kYEq
|
||
|
jr nz,ss_loop
|
||
|
ld hl,wpp
|
||
|
ld a,(lvldone)
|
||
|
ld b,a
|
||
|
ld a,(x2)
|
||
|
or a
|
||
|
ld a,(y2)
|
||
|
jr z,wpn_left
|
||
|
wpn_left:
|
||
|
ld c,0
|
||
|
ld hl,wpp
|
||
|
cp 1
|
||
|
jp z,ss_exit
|
||
|
cp 11
|
||
|
jr z,ss_an
|
||
|
ss_an:
|
||
|
bit 0,b
|
||
|
jr z,ss_loop
|
||
|
ld c,1
|
||
|
ld a,(enan)
|
||
|
ld (enwpn),a
|
||
|
ld hl,wpan
|
||
|
jp ss_exit
|
||
|
ss_exit:
|
||
|
ld a,c
|
||
|
ld (wpn),a
|
||
|
ld (wpnspr),hl
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
call ShowLevel
|
||
|
pop af
|
||
|
call tiny_delay
|
||
|
ret
|
||
|
ss_mode:
|
||
|
pop bc ; pop to something other than af so it remembers that MODE has been pressed
|
||
|
ret
|
||
|
ss_up:
|
||
|
ld a,(y2)
|
||
|
cp 1
|
||
|
jr z,ss_vert
|
||
|
sub 10
|
||
|
ld (y2),a
|
||
|
jp ss_loop_new
|
||
|
ss_down:
|
||
|
ld a,(y2)
|
||
|
cp 41
|
||
|
jr z,ss_vert
|
||
|
add a,10
|
||
|
ld (y2),a
|
||
|
jp ss_loop_new
|
||
|
ss_vert:
|
||
|
ld b,a
|
||
|
ld a,42
|
||
|
sub b
|
||
|
ld (y2),a
|
||
|
jp ss_loop_new
|
||
|
ss_horz:
|
||
|
ld a,(x2)
|
||
|
ld b,a
|
||
|
ld a,47
|
||
|
sub b
|
||
|
ld (x2),a
|
||
|
jp ss_loop_new
|
||
|
ss_tank:
|
||
|
ld a,(tanks)
|
||
|
or a
|
||
|
jp z,ss_loop_new
|
||
|
dec a
|
||
|
ld (tanks),a
|
||
|
ld a,28
|
||
|
ld (enp),a
|
||
|
jp ss_loop_new
|
||
|
xor_char:
|
||
|
ld ix,(curpic)
|
||
|
ld b,12
|
||
|
ld a,(ymm)
|
||
|
ld l,a
|
||
|
ld a,(xmm)
|
||
|
call isprite
|
||
|
ret
|
||
|
check_spr:
|
||
|
ld a,(dir)
|
||
|
or a
|
||
|
jr z,check_spr_l
|
||
|
check_spr_r:
|
||
|
ld hl,mmhr
|
||
|
ld a,(hchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
ld a,(ymm)
|
||
|
add a,12
|
||
|
call CheckVert
|
||
|
jr c,not_jump_r
|
||
|
ld hl,mmjr
|
||
|
ld a,(jchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
not_jump_r:
|
||
|
ld hl,mmwr
|
||
|
ld a,(wchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
ret
|
||
|
check_spr_l:
|
||
|
ld hl,mmhl
|
||
|
ld a,(hchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
ld a,(ymm)
|
||
|
add a,12
|
||
|
call CheckVert
|
||
|
jr c,not_jump_l
|
||
|
ld hl,mmjl
|
||
|
ld a,(jchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
not_jump_l:
|
||
|
ld hl,mmwl
|
||
|
ld a,(wchk)
|
||
|
or a
|
||
|
jr nz,found_spr
|
||
|
ret
|
||
|
found_spr:
|
||
|
ld (curpic),hl
|
||
|
ret
|
||
|
find_spr:
|
||
|
ld a,(dir)
|
||
|
or a
|
||
|
jr z,left_spr
|
||
|
ld hl,mmsr
|
||
|
jr found_spr
|
||
|
left_spr:
|
||
|
ld hl,mmsl
|
||
|
jr found_spr
|
||
|
t_move:
|
||
|
call xor_en
|
||
|
call check_en_dist
|
||
|
ld a,(edir)
|
||
|
or a
|
||
|
ld a,(xe)
|
||
|
jr z,t_move_l
|
||
|
inc a
|
||
|
jr t_move_r
|
||
|
t_move_l:
|
||
|
dec a
|
||
|
or a
|
||
|
call z,en_dead
|
||
|
t_move_r:
|
||
|
ld (xe),a
|
||
|
ret
|
||
|
i_move:
|
||
|
call xor_en
|
||
|
call check_en_dist
|
||
|
ld a,(edir)
|
||
|
or a
|
||
|
ld a,(ye)
|
||
|
jr z,i_move_u
|
||
|
inc a
|
||
|
jr i_move_d
|
||
|
i_move_u:
|
||
|
dec a
|
||
|
i_move_d:
|
||
|
ld (ye),a
|
||
|
ret
|
||
|
ti_check:
|
||
|
ld a,(echk)
|
||
|
cp 3
|
||
|
jr nz,tic_cont
|
||
|
xor a
|
||
|
ld (echk),a
|
||
|
tic_cont:
|
||
|
ld b,46
|
||
|
ld c,46
|
||
|
ld a,(bcount)
|
||
|
inc a
|
||
|
ld (bcount),a
|
||
|
cp 50
|
||
|
ld a,7
|
||
|
call z,item_init
|
||
|
ld a,(bcount)
|
||
|
cp 100
|
||
|
ld a,9
|
||
|
call z,item_init
|
||
|
ld a,(bcount)
|
||
|
cp 100
|
||
|
ret nz
|
||
|
xor a
|
||
|
ld (bcount),a
|
||
|
ret
|
||
|
ship_check:
|
||
|
ld a,(bcount)
|
||
|
inc a
|
||
|
cp 50
|
||
|
jr z,ship_laser
|
||
|
ld (bcount),a
|
||
|
ret
|
||
|
ship_laser:
|
||
|
xor a
|
||
|
ld (bcount),a
|
||
|
ld b,1
|
||
|
call xor_laser
|
||
|
call short_delay
|
||
|
ld a,(ymm)
|
||
|
cp 38
|
||
|
call c,die
|
||
|
ld b,0
|
||
|
call xor_laser
|
||
|
ret
|
||
|
boss_move:
|
||
|
call xor_boss
|
||
|
ld a,(boss)
|
||
|
or a
|
||
|
jr z,ti_check
|
||
|
cp 5
|
||
|
jr z,ship_check
|
||
|
ld a,(bjchk)
|
||
|
or a
|
||
|
jr nz,boss_jump
|
||
|
ld a,(bdir)
|
||
|
or a
|
||
|
ld a,(xb)
|
||
|
jr z,boss_move_l
|
||
|
inc a
|
||
|
cp 76
|
||
|
jr boss_move_r
|
||
|
boss_move_l:
|
||
|
dec a
|
||
|
cp 56
|
||
|
boss_move_r:
|
||
|
ld (xb),a
|
||
|
jr z,boss_turn
|
||
|
cp 66
|
||
|
call z,boss_shoot
|
||
|
ret
|
||
|
boss_turn:
|
||
|
ld a,(bdir) ; reverse dir boss is moving
|
||
|
ld b,a
|
||
|
ld a,1
|
||
|
sub b
|
||
|
ld (bdir),a
|
||
|
ld a,2
|
||
|
ld (bjchk),a
|
||
|
ret
|
||
|
boss_jump:
|
||
|
ld a,(bjchk)
|
||
|
cp 1
|
||
|
ld a,(yb)
|
||
|
jr z,boss_fall
|
||
|
dec a
|
||
|
cp 34
|
||
|
jr boss_jump_end
|
||
|
boss_fall:
|
||
|
inc a
|
||
|
cp 44
|
||
|
boss_jump_end:
|
||
|
ld (yb),a
|
||
|
ret nz
|
||
|
ld a,(bjchk)
|
||
|
dec a
|
||
|
ld (bjchk),a
|
||
|
ret
|
||
|
bshoot_sa:
|
||
|
ld a,(xb)
|
||
|
ld (bwx),a
|
||
|
call xor_boss
|
||
|
ret
|
||
|
bshoot_fr:
|
||
|
ld a,(xb)
|
||
|
ld (bwx),a
|
||
|
ret
|
||
|
bshoot_md:
|
||
|
ld a,(xb)
|
||
|
sub 8
|
||
|
ld (bwx),a
|
||
|
ret
|
||
|
boss_shoot:
|
||
|
ld a,(bwchk)
|
||
|
or a
|
||
|
ret nz
|
||
|
inc a
|
||
|
ld (bwchk),a
|
||
|
ld a,(boss)
|
||
|
cp 3
|
||
|
jr z,bshoot_md
|
||
|
cp 7
|
||
|
jr z,bshoot_fr
|
||
|
cp 8
|
||
|
jr z,bshoot_sa
|
||
|
ld a,58
|
||
|
ld (bwx),a
|
||
|
ret
|
||
|
bssa_move:
|
||
|
call xor_boss
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
bssam_loop:
|
||
|
ld a,(bwx)
|
||
|
dec a
|
||
|
ld (bwx),a
|
||
|
call xor_bwpn
|
||
|
call fastcopys
|
||
|
call xor_bwpn
|
||
|
ld a,(bwx)
|
||
|
or a
|
||
|
jr nz,bssam_loop
|
||
|
bssam_loop2:
|
||
|
ld a,(bwx)
|
||
|
inc a
|
||
|
ld (bwx),a
|
||
|
call xor_bwpn
|
||
|
call fastcopys
|
||
|
call xor_bwpn
|
||
|
ld a,(bwx)
|
||
|
cp 88
|
||
|
jr nz,bssam_loop2
|
||
|
bssam_loop3:
|
||
|
ld a,(bwx)
|
||
|
dec a
|
||
|
ld (bwx),a
|
||
|
call xor_bwpn
|
||
|
call fastcopys
|
||
|
call xor_bwpn
|
||
|
ld a,(xb)
|
||
|
ld b,a
|
||
|
ld a,(bwx)
|
||
|
cp b
|
||
|
jr nz,bssam_loop3
|
||
|
xor a
|
||
|
ld (bwchk),a
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,37
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,16
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 4
|
||
|
jr nc,bssam_nokill
|
||
|
xor a
|
||
|
bssam_nokill:
|
||
|
ld (enp),a
|
||
|
ret
|
||
|
bsfr_move:
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
call xor_boss
|
||
|
call xor_bwpn
|
||
|
call fastcopys
|
||
|
call xor_char
|
||
|
call xor_boss
|
||
|
call xor_bwpn
|
||
|
call short_delay
|
||
|
xor a
|
||
|
ld (bwchk),a
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,55
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,22
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,33
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,11
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 4
|
||
|
jr nc,bsfrm_nokill
|
||
|
xor a
|
||
|
bsfrm_nokill:
|
||
|
ld (enp),a
|
||
|
ret
|
||
|
bsmd_move:
|
||
|
call short_delay
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 4
|
||
|
jr nc,bsmdm_nokill
|
||
|
xor a
|
||
|
bsmdm_nokill:
|
||
|
ld (enp),a
|
||
|
xor a
|
||
|
ld (bwchk),a
|
||
|
ret
|
||
|
boss_shot_move:
|
||
|
call xor_bwpn
|
||
|
ld a,(boss)
|
||
|
cp 8
|
||
|
jp z,bssa_move
|
||
|
cp 3
|
||
|
jr z,bsmd_move
|
||
|
cp 7
|
||
|
jr z,bsfr_move
|
||
|
ld a,(xb)
|
||
|
ld b,a
|
||
|
ld a,(bwx)
|
||
|
cp 2
|
||
|
jr c,bsm_end
|
||
|
cp b
|
||
|
jr z,bsm_end
|
||
|
ld b,a
|
||
|
bsm_cont:
|
||
|
dec b
|
||
|
dec b
|
||
|
ld a,(boss)
|
||
|
cp 4
|
||
|
jr nz,bsm_store
|
||
|
dec b
|
||
|
bsm_store:
|
||
|
ld a,b
|
||
|
ld (bwx),a
|
||
|
ret
|
||
|
bsm_end:
|
||
|
xor a ; boss's shot is off the screen
|
||
|
ld (bwchk),a
|
||
|
ret
|
||
|
check_en_dist: ; check distance enemy has moved and turn around if necessary
|
||
|
ld a,(ecount)
|
||
|
inc a
|
||
|
cp 33
|
||
|
call z,en_turn
|
||
|
ld (ecount),a
|
||
|
ret
|
||
|
en_turn:
|
||
|
ld hl,(enspr)
|
||
|
ld de,8
|
||
|
ld a,(edir)
|
||
|
or a
|
||
|
jr z,en_turn_r
|
||
|
sbc hl,de
|
||
|
dec a
|
||
|
jr en_turn_l
|
||
|
en_turn_r:
|
||
|
add hl,de
|
||
|
inc a
|
||
|
en_turn_l:
|
||
|
ld (enspr),hl
|
||
|
ld (edir),a
|
||
|
xor a
|
||
|
ret
|
||
|
en_dead: ; enemy is now dead
|
||
|
ld a,3
|
||
|
ld (echk),a
|
||
|
xor a
|
||
|
ld (ecount),a
|
||
|
ret
|
||
|
next_en: ; check if previous enemy is clear so next enemy can initialize
|
||
|
ld a,(ecount2)
|
||
|
inc a
|
||
|
ld (ecount2),a
|
||
|
cp 96
|
||
|
ret nz
|
||
|
xor a
|
||
|
ld (echk),a
|
||
|
ret
|
||
|
xor_en:
|
||
|
ld ix,(enspr)
|
||
|
ld b,8
|
||
|
ld a,(ye)
|
||
|
ld l,a
|
||
|
ld a,(xe)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_corners:
|
||
|
ld hl,uprlft
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld a,(x2)
|
||
|
add a,22
|
||
|
ld (x2),a
|
||
|
ld hl,uprrt
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld a,(y2)
|
||
|
add a,12
|
||
|
ld (y2),a
|
||
|
ld hl,lwrrt
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld a,(x2)
|
||
|
sub 22
|
||
|
ld (x2),a
|
||
|
ld hl,lwrlft
|
||
|
ld (smlspr),hl
|
||
|
call xor_8x8
|
||
|
ld a,(y2)
|
||
|
sub 12
|
||
|
ld (y2),a
|
||
|
ret
|
||
|
xor_8x8:
|
||
|
ld ix,(smlspr)
|
||
|
ld b,8
|
||
|
ld a,(y2)
|
||
|
ld l,a
|
||
|
ld a,(x2)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_wpn1:
|
||
|
ld ix,(wpnspr)
|
||
|
ld b,4
|
||
|
ld a,(wy1)
|
||
|
ld l,a
|
||
|
ld a,(wx1)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_wpn2:
|
||
|
ld ix,(wpnspr)
|
||
|
ld b,4
|
||
|
ld a,(wy2)
|
||
|
ld l,a
|
||
|
ld a,(wx2)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_wpn3:
|
||
|
ld b,4
|
||
|
ld a,(wy3)
|
||
|
ld l,a
|
||
|
ld a,(wx3)
|
||
|
ld ix,(wpnspr)
|
||
|
call isprite
|
||
|
ret
|
||
|
xor_bwpn:
|
||
|
ld b,4
|
||
|
ld l,49
|
||
|
ld a,(bwx)
|
||
|
ld ix,(bwspr)
|
||
|
call isprite
|
||
|
ret
|
||
|
tiny_delay:
|
||
|
ld b,20
|
||
|
jr del_loop
|
||
|
short_delay:
|
||
|
ld b,50
|
||
|
jr del_loop
|
||
|
long_delay:
|
||
|
call delay
|
||
|
med_delay:
|
||
|
ld b,100
|
||
|
jr del_loop
|
||
|
delay:
|
||
|
ld b,200
|
||
|
del_loop:
|
||
|
halt
|
||
|
halt
|
||
|
djnz del_loop
|
||
|
ret
|
||
|
disp_boss:
|
||
|
ld (bosspic),hl
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
xor a
|
||
|
ld (x2),a
|
||
|
ld a,16
|
||
|
ld (y2),a
|
||
|
ld hl,bint
|
||
|
ld (smlspr),hl
|
||
|
ld b,12
|
||
|
draw1:
|
||
|
push bc
|
||
|
call xor_8x8
|
||
|
ld a,(x2)
|
||
|
add a,8
|
||
|
ld (x2),a
|
||
|
pop bc
|
||
|
djnz draw1
|
||
|
ld a,0
|
||
|
ld (x2),a
|
||
|
ld a,40
|
||
|
ld (y2),a
|
||
|
ld hl,bint
|
||
|
ld (smlspr),hl
|
||
|
ld b,12
|
||
|
draw2:
|
||
|
push bc
|
||
|
call xor_8x8
|
||
|
ld a,(x2)
|
||
|
add a,8
|
||
|
ld (x2),a
|
||
|
pop bc
|
||
|
djnz draw2
|
||
|
call xor_boss
|
||
|
call fastcopys
|
||
|
ret
|
||
|
xor_boss:
|
||
|
ld b,12
|
||
|
ld a,(yb)
|
||
|
ld l,a
|
||
|
ld a,(xb)
|
||
|
ld ix,(bosspic)
|
||
|
call isprite
|
||
|
ret
|
||
|
no_an:
|
||
|
call draw
|
||
|
ret
|
||
|
no_ma:
|
||
|
call draw
|
||
|
ret
|
||
|
no_md:
|
||
|
call draw
|
||
|
ret
|
||
|
no_do:
|
||
|
call draw
|
||
|
ret
|
||
|
no_po:
|
||
|
call draw
|
||
|
ret
|
||
|
no_fr:
|
||
|
call draw
|
||
|
ret
|
||
|
no_sa:
|
||
|
call draw
|
||
|
ret
|
||
|
no_mi:
|
||
|
call draw
|
||
|
ret
|
||
|
you_got:
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
call draw
|
||
|
ld hl,35
|
||
|
ld (xmm),hl
|
||
|
ld a,50
|
||
|
ld (ymm),a
|
||
|
ld hl,mmsr
|
||
|
ld (curpic),hl
|
||
|
ld a,43
|
||
|
ld (wx1),a
|
||
|
ld a,51
|
||
|
ld (wy1),a
|
||
|
ld a,(boss)
|
||
|
cp 3
|
||
|
jr z,yg_cont
|
||
|
ld hl,mmwr
|
||
|
ld (curpic),hl
|
||
|
ld a,55
|
||
|
ld (wx1),a
|
||
|
ld a,55
|
||
|
ld (wy1),a
|
||
|
ld a,(boss)
|
||
|
ld hl,wpan
|
||
|
cp 1
|
||
|
jr z,yg_cont
|
||
|
cp 2
|
||
|
jr z,yg_cont
|
||
|
cp 4
|
||
|
jr z,yg_cont
|
||
|
cp 6
|
||
|
jr z,yg_cont
|
||
|
cp 9
|
||
|
jr z,yg_cont
|
||
|
push af
|
||
|
ld a,35
|
||
|
ld (wx1),a
|
||
|
ld a,54
|
||
|
ld (wy1),a
|
||
|
call xor_char
|
||
|
pop af
|
||
|
cp 8
|
||
|
jr z,yg_cont
|
||
|
ld (wpnspr),hl
|
||
|
call xor_wpn1
|
||
|
ld a,50
|
||
|
ld (wy1),a
|
||
|
call xor_wpn1
|
||
|
ld a,58
|
||
|
ld (wy1),a
|
||
|
yg_cont:
|
||
|
ld (wpnspr),hl
|
||
|
call xor_wpn1
|
||
|
call xor_char
|
||
|
call fastcopys
|
||
|
ld de,10*256+35
|
||
|
ld hl,yougot
|
||
|
call setvputs
|
||
|
ld a,(boss)
|
||
|
cp 1
|
||
|
jr z,yg_an
|
||
|
jr yg_mi
|
||
|
yg_an:
|
||
|
ld de,20*256+28
|
||
|
ld hl,ygan
|
||
|
call setvputs
|
||
|
jr yg_loop
|
||
|
yg_mi:
|
||
|
ld de,20*256+28
|
||
|
ld hl,ygmi
|
||
|
call setvputs
|
||
|
yg_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp kMode
|
||
|
ret z
|
||
|
cp kEnter
|
||
|
jr nz,yg_loop
|
||
|
ret
|
||
|
draw_grid:
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
call draw
|
||
|
ret
|
||
|
pw_text:
|
||
|
ld de,1*256+31
|
||
|
ld hl,one
|
||
|
call setvputs
|
||
|
ld de,1*256+40
|
||
|
ld hl,two
|
||
|
call setvputs
|
||
|
ld de,1*256+49
|
||
|
ld hl,three
|
||
|
call setvputs
|
||
|
ld de,1*256+58
|
||
|
ld hl,four
|
||
|
call setvputs
|
||
|
ld de,1*256+67
|
||
|
ld hl,five
|
||
|
call setvputs
|
||
|
ld de,10*256+23
|
||
|
ld hl,a
|
||
|
call setvputs
|
||
|
ld de,19*256+23
|
||
|
ld hl,b
|
||
|
call setvputs
|
||
|
ld de,28*256+23
|
||
|
ld hl,c
|
||
|
call setvputs
|
||
|
ld de,37*256+23
|
||
|
ld hl,d
|
||
|
call setvputs
|
||
|
ld de,46*256+23
|
||
|
ld hl,e
|
||
|
call setvputs
|
||
|
ld de,56*256+32
|
||
|
ld hl,enter
|
||
|
call setvputs
|
||
|
ret
|
||
|
show_pw:
|
||
|
call draw_grid
|
||
|
ld a,(tanks) ; find correct password dot for number of tanks
|
||
|
ld b,1
|
||
|
or a
|
||
|
jr z,spw_cont
|
||
|
ld b,2
|
||
|
cp 1
|
||
|
jr z,spw_cont
|
||
|
ld b,4
|
||
|
cp 2
|
||
|
jr z,spw_cont
|
||
|
ld b,8
|
||
|
cp 3
|
||
|
jr z,spw_cont
|
||
|
ld b,16
|
||
|
spw_cont:
|
||
|
ld a,b
|
||
|
ld (tankpw),a
|
||
|
ld hl,pwdot
|
||
|
ld (smlspr),hl
|
||
|
ld a,(lvldone)
|
||
|
bit 0,a
|
||
|
jr z,no_an_dot
|
||
|
ld a,28
|
||
|
jr an_dot
|
||
|
no_an_dot:
|
||
|
ld a,46
|
||
|
an_dot:
|
||
|
ld (y2),a
|
||
|
ld a,47
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 1,a
|
||
|
jr z,no_ma_dot
|
||
|
ld a,10
|
||
|
ld (y2),a
|
||
|
ld a,38
|
||
|
jr ma_dot
|
||
|
no_ma_dot:
|
||
|
ld a,28
|
||
|
ld (y2),a
|
||
|
ld a,65
|
||
|
ma_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 2,a
|
||
|
jr z,no_md_dot
|
||
|
ld a,46
|
||
|
ld (y2),a
|
||
|
ld a,65
|
||
|
jr md_dot
|
||
|
no_md_dot:
|
||
|
ld a,10
|
||
|
ld (y2),a
|
||
|
ld a,56
|
||
|
md_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 3,a
|
||
|
jr z,no_do_dot
|
||
|
ld a,37
|
||
|
ld (y2),a
|
||
|
ld a,47
|
||
|
jr do_dot
|
||
|
no_do_dot:
|
||
|
ld a,46
|
||
|
ld (y2),a
|
||
|
ld a,38
|
||
|
do_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 4,a
|
||
|
jr z,no_po_dot
|
||
|
ld a,37
|
||
|
ld (y2),a
|
||
|
ld a,29
|
||
|
jr po_dot
|
||
|
no_po_dot:
|
||
|
ld a,19
|
||
|
ld (y2),a
|
||
|
ld a,65
|
||
|
po_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 5,a
|
||
|
jr z,no_fr_dot
|
||
|
ld a,56
|
||
|
jr fr_dot
|
||
|
no_fr_dot:
|
||
|
ld a,29
|
||
|
fr_dot:
|
||
|
ld (x2),a
|
||
|
ld a,19
|
||
|
ld (y2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 5,a
|
||
|
jr z,no_se_dot
|
||
|
ld a,46
|
||
|
ld (y2),a
|
||
|
ld a,29
|
||
|
jr se_dot
|
||
|
no_se_dot:
|
||
|
ld a,28
|
||
|
ld (y2),a
|
||
|
ld a,56
|
||
|
se_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 6,a
|
||
|
jr z,no_sa_dot
|
||
|
ld a,38
|
||
|
jr sa_dot
|
||
|
no_sa_dot:
|
||
|
ld a,47
|
||
|
sa_dot:
|
||
|
ld (x2),a
|
||
|
ld a,19
|
||
|
ld (y2),a
|
||
|
call xor_8x8
|
||
|
ld a,(lvldone)
|
||
|
bit 7,a
|
||
|
jr z,no_mi_dot
|
||
|
ld a,28
|
||
|
ld (y2),a
|
||
|
ld a,38
|
||
|
jr mi_dot
|
||
|
no_mi_dot:
|
||
|
ld a,37
|
||
|
ld (y2),a
|
||
|
ld a,56
|
||
|
mi_dot:
|
||
|
ld (x2),a
|
||
|
call xor_8x8
|
||
|
tank_dot:
|
||
|
ld a,(tankpw)
|
||
|
ld b,a
|
||
|
ld a,10
|
||
|
ld (y2),a
|
||
|
ld a,47
|
||
|
ld (x2),a
|
||
|
bit 0,b
|
||
|
jr nz,tank_dot_found
|
||
|
ld a,46
|
||
|
ld (y2),a
|
||
|
ld a,56
|
||
|
ld (x2),a
|
||
|
bit 1,b
|
||
|
jr nz,tank_dot_found
|
||
|
ld a,28
|
||
|
ld (y2),a
|
||
|
ld a,29
|
||
|
ld (x2),a
|
||
|
bit 2,b
|
||
|
jr nz,tank_dot_found
|
||
|
ld a,10
|
||
|
ld (y2),a
|
||
|
ld a,65
|
||
|
ld (x2),a
|
||
|
bit 3,b
|
||
|
jr nz,tank_dot_found
|
||
|
ld a,37
|
||
|
ld (y2),a
|
||
|
ld a,38
|
||
|
ld (x2),a
|
||
|
tank_dot_found:
|
||
|
call xor_8x8
|
||
|
call fastcopys
|
||
|
call pw_text
|
||
|
show_pw_loop:
|
||
|
bcall(_getcsc)
|
||
|
cp kMode
|
||
|
ret z
|
||
|
cp kEnter
|
||
|
jr nz,show_pw_loop
|
||
|
ret
|
||
|
ship_init:
|
||
|
ld a,(bchk)
|
||
|
or a
|
||
|
ret z
|
||
|
call draw
|
||
|
ld a,56
|
||
|
ld (xb),a
|
||
|
ld a,16
|
||
|
ld (yb),a
|
||
|
ret
|
||
|
xor_laser:
|
||
|
call draw
|
||
|
call check_spr
|
||
|
call xor_char
|
||
|
call xor_boss
|
||
|
call fastcopys
|
||
|
call draw
|
||
|
call xor_char
|
||
|
call xor_boss
|
||
|
ret
|
||
|
wpn_fill:
|
||
|
ld a,28
|
||
|
ld (enp),a
|
||
|
ld (enan),a
|
||
|
ld (enma),a
|
||
|
ld (enmd),a
|
||
|
ld (endo),a
|
||
|
ld (ense),a
|
||
|
ld (enpo),a
|
||
|
ld (enfr),a
|
||
|
ld (ensa),a
|
||
|
ld (enmi),a
|
||
|
ld (enwpn),a
|
||
|
ret
|
||
|
draw_nrg:
|
||
|
ld a,(bchk)
|
||
|
or a
|
||
|
call nz,draw_bnrg
|
||
|
ld d,10
|
||
|
ld e,38
|
||
|
ld h,10
|
||
|
ld a,(enp)
|
||
|
ld b,a
|
||
|
ld a,37
|
||
|
sub b
|
||
|
ld l,a
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ld a,(wpn)
|
||
|
or a
|
||
|
ret z
|
||
|
ld d,12 ; draw weapon energy line
|
||
|
ld e,38
|
||
|
ld h,12
|
||
|
ld a,(enwpn)
|
||
|
ld b,a
|
||
|
ld a,37
|
||
|
sub b
|
||
|
ld l,a
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ret
|
||
|
draw_bnrg:
|
||
|
ld d,86
|
||
|
ld e,38
|
||
|
ld h,86
|
||
|
ld a,(enb)
|
||
|
ld b,a
|
||
|
ld a,37
|
||
|
sub b
|
||
|
ld l,a
|
||
|
ld a,1
|
||
|
call fastline
|
||
|
ret
|
||
|
check_ehitu:
|
||
|
ld a,(echk)
|
||
|
cp 3
|
||
|
ret z
|
||
|
ld a,(wx1)
|
||
|
ld d,a
|
||
|
ld a,(wy1)
|
||
|
ld e,a
|
||
|
ld a,(wchk1)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_white
|
||
|
ld a,c
|
||
|
ld (wchk1),a
|
||
|
ld a,(wx2)
|
||
|
ld d,a
|
||
|
ld a,(wy2)
|
||
|
ld e,a
|
||
|
ld a,(wchk2)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_white
|
||
|
ld a,c
|
||
|
ld (wchk2),a
|
||
|
ld a,(wx3)
|
||
|
ld d,a
|
||
|
ld a,(wy3)
|
||
|
ld e,a
|
||
|
ld a,(wchk3)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_white
|
||
|
ld a,c
|
||
|
ld (wchk3),a
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(xe)
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,(ye)
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,18
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,ehitu_nokill
|
||
|
xor a
|
||
|
ehitu_nokill:
|
||
|
ld (enp),a
|
||
|
ld a,1
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
check_bhitu:
|
||
|
ld a,(wx1)
|
||
|
ld d,a
|
||
|
ld a,(wy1)
|
||
|
ld e,a
|
||
|
ld a,(wchk1)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_whitb
|
||
|
ld a,c
|
||
|
ld (wchk1),a
|
||
|
ld a,(wx2)
|
||
|
ld d,a
|
||
|
ld a,(wy2)
|
||
|
ld e,a
|
||
|
ld a,(wchk2)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_whitb
|
||
|
ld a,c
|
||
|
ld (wchk2),a
|
||
|
ld a,(wx3)
|
||
|
ld d,a
|
||
|
ld a,(wy3)
|
||
|
ld e,a
|
||
|
ld a,(wchk3)
|
||
|
ld c,a
|
||
|
or a
|
||
|
call nz,check_whitb
|
||
|
ld a,c
|
||
|
ld (wchk3),a
|
||
|
ld a,(boss)
|
||
|
cp 5
|
||
|
jr z,check_shitu
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(xb)
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,(yb)
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,22
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 7
|
||
|
jr nc,bhitu_nokill
|
||
|
xor a
|
||
|
bhitu_nokill:
|
||
|
ld (enp),a
|
||
|
ld a,1
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
check_shitu:
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,28
|
||
|
cp b
|
||
|
ret nc
|
||
|
xor a
|
||
|
ld (enp),a
|
||
|
ld a,1
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
check_bwhitu:
|
||
|
ld a,(xmm)
|
||
|
ld b,a
|
||
|
ld a,(bwx)
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ymm)
|
||
|
ld b,a
|
||
|
ld a,38
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(enp)
|
||
|
or a
|
||
|
sub 2
|
||
|
jr nc,bwhitu_nokill
|
||
|
xor a
|
||
|
bwhitu_nokill:
|
||
|
ld (enp),a
|
||
|
ld a,1
|
||
|
ld (hchk),a
|
||
|
ret
|
||
|
check_white:
|
||
|
ld a,(xe)
|
||
|
ld b,a
|
||
|
ld a,d
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(ye)
|
||
|
ld b,a
|
||
|
ld a,e
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,10
|
||
|
cp b
|
||
|
ret c
|
||
|
ld c,0
|
||
|
ld a,(ene)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,white_nokill
|
||
|
xor a
|
||
|
white_nokill:
|
||
|
ld (ene),a
|
||
|
or a
|
||
|
ret nz
|
||
|
ld a,3
|
||
|
ld (echk),a
|
||
|
ret
|
||
|
check_whitb:
|
||
|
ld a,(boss)
|
||
|
cp 5
|
||
|
jr z,check_whits
|
||
|
ld a,(xb)
|
||
|
ld b,a
|
||
|
ld a,d
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld a,(yb)
|
||
|
ld b,a
|
||
|
ld a,e
|
||
|
sub 11
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld c,0
|
||
|
call dam7_or1
|
||
|
ld a,(enb)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,whitb_nokill
|
||
|
xor a
|
||
|
whitb_nokill:
|
||
|
ld (enb),a
|
||
|
ret nz
|
||
|
call won
|
||
|
ret
|
||
|
check_whits:
|
||
|
ld b,35
|
||
|
ld a,d
|
||
|
sub 7
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,14
|
||
|
cp b
|
||
|
ret c
|
||
|
ld b,42
|
||
|
ld a,e
|
||
|
cp b
|
||
|
ret nc
|
||
|
add a,10
|
||
|
cp b
|
||
|
ret c
|
||
|
ld c,0
|
||
|
call dam7_or1
|
||
|
ld a,(enb)
|
||
|
or a
|
||
|
sub 1
|
||
|
jr nc,whits_nokill
|
||
|
xor a
|
||
|
whits_nokill:
|
||
|
ld (enb),a
|
||
|
or a
|
||
|
ret nz
|
||
|
call won
|
||
|
ret
|
||
|
dam7_or1:
|
||
|
ld a,(wpn)
|
||
|
or a
|
||
|
ret z
|
||
|
cp 5
|
||
|
ret z
|
||
|
cp 1
|
||
|
jr z,an_on_po
|
||
|
cp 2
|
||
|
jr z,ma_on_do
|
||
|
cp 3
|
||
|
jr z,md_on_sa
|
||
|
cp 4
|
||
|
jr z,do_on_fr
|
||
|
cp 6
|
||
|
jr z,po_on_md
|
||
|
cp 7
|
||
|
jr z,fr_on_an
|
||
|
cp 8
|
||
|
jr z,sa_on_mi
|
||
|
cp 9
|
||
|
jr z,mi_on_ma
|
||
|
ret
|
||
|
an_on_po:
|
||
|
ld a,(boss)
|
||
|
cp 5
|
||
|
jr z,damage7
|
||
|
cp 6
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
ma_on_do:
|
||
|
ld a,(boss)
|
||
|
or a
|
||
|
jr z,damage7
|
||
|
cp 4
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
md_on_sa:
|
||
|
ld a,(boss)
|
||
|
cp 8
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
do_on_fr:
|
||
|
ld a,(boss)
|
||
|
cp 7
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
po_on_md:
|
||
|
ld a,(boss)
|
||
|
cp 3
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
fr_on_an:
|
||
|
ld a,(boss)
|
||
|
cp 1
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
sa_on_mi:
|
||
|
ld a,(boss)
|
||
|
cp 9
|
||
|
ret nz
|
||
|
jr damage7
|
||
|
mi_on_ma:
|
||
|
ld a,(boss)
|
||
|
cp 2
|
||
|
ret nz
|
||
|
damage7:
|
||
|
ld a,(enb)
|
||
|
or a
|
||
|
sub 6
|
||
|
jr nc,dam7_nokill
|
||
|
call won
|
||
|
xor a
|
||
|
dam7_nokill:
|
||
|
ld (enb),a
|
||
|
ret
|
||
|
thrown_back:
|
||
|
xor a
|
||
|
ld (hchk),a
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
or a
|
||
|
ld de,8
|
||
|
sbc hl,de
|
||
|
push hl
|
||
|
push hl
|
||
|
call CheckHorz
|
||
|
pop hl
|
||
|
call z,CheckHorz2
|
||
|
pop hl
|
||
|
call z,CheckHorz3
|
||
|
jr nz,thrown_short
|
||
|
ld a,(xmm)
|
||
|
sub 8
|
||
|
ld (xmm),a
|
||
|
ret
|
||
|
thrown_short:
|
||
|
ld hl,(xmm)
|
||
|
call load_x
|
||
|
push hl
|
||
|
srl h
|
||
|
rr l
|
||
|
srl h
|
||
|
rr l
|
||
|
srl h
|
||
|
rr l ; divide x by 8
|
||
|
add hl,hl
|
||
|
add hl,hl
|
||
|
add hl,hl ; multiply x by 8
|
||
|
push hl
|
||
|
pop de
|
||
|
pop hl
|
||
|
or a
|
||
|
sbc hl,de
|
||
|
push hl
|
||
|
ld hl,(xmm)
|
||
|
pop de
|
||
|
or a
|
||
|
sbc hl,de
|
||
|
ld (xmm),hl
|
||
|
ret
|
||
|
draw_text:
|
||
|
;hl = pointer to text info
|
||
|
ld a,(hl)
|
||
|
ld e,a
|
||
|
inc hl
|
||
|
push de
|
||
|
push hl
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
ld a,1
|
||
|
pop hl
|
||
|
pop de
|
||
|
draw_txt_loop:
|
||
|
push af
|
||
|
push de
|
||
|
push hl
|
||
|
call centertext
|
||
|
pop hl
|
||
|
pop de
|
||
|
pop af
|
||
|
add a,6
|
||
|
cp 59
|
||
|
call nc,reseta_draw
|
||
|
push af
|
||
|
ld a,$00
|
||
|
ld b,255
|
||
|
cpir
|
||
|
pop af
|
||
|
dec e
|
||
|
jr nz,draw_txt_loop
|
||
|
call clrwait
|
||
|
ret
|
||
|
|
||
|
reseta_draw:
|
||
|
push af
|
||
|
push de
|
||
|
push hl
|
||
|
dec e
|
||
|
call nz,clrwait
|
||
|
inc e
|
||
|
pop hl
|
||
|
pop de
|
||
|
pop af
|
||
|
ld a,1
|
||
|
ret
|
||
|
clrwait:
|
||
|
call wait
|
||
|
bcall(_clrlcdfull)
|
||
|
bcall(_grbufclr)
|
||
|
ret
|
||
|
wait:
|
||
|
bcall(_getcsc)
|
||
|
or a
|
||
|
jr z,wait
|
||
|
ret
|
||
|
quit_force:
|
||
|
|
||
|
draw:
|
||
|
push af
|
||
|
push bc
|
||
|
push de
|
||
|
ld a,(hl)
|
||
|
ld b,a
|
||
|
inc hl
|
||
|
ld a,(hl)
|
||
|
inc hl
|
||
|
drawloop:
|
||
|
;hl = pointer to line data
|
||
|
;a = draw mode (0=off 1=on 2=xor 3=pattern)
|
||
|
;b = number of lines
|
||
|
push bc
|
||
|
ld c,(hl)
|
||
|
inc hl
|
||
|
ld b,(hl)
|
||
|
inc hl
|
||
|
ld e,(hl)
|
||
|
inc hl
|
||
|
ld d,(hl)
|
||
|
inc hl
|
||
|
push af
|
||
|
push hl
|
||
|
push bc
|
||
|
push de
|
||
|
pop de
|
||
|
pop hl
|
||
|
call fastline
|
||
|
pop hl
|
||
|
pop af
|
||
|
pop bc
|
||
|
djnz drawloop
|
||
|
pop de
|
||
|
pop bc
|
||
|
pop af
|
||
|
ret
|