;1) Working on a new pickup-system allowing more than one "food" and different pickup-handling
-#include "TI86.inc"
+#include "asm86.h"
+#include "ti86asm.inc"
+#include "ti86abs.inc"
+
+_SHRACC = $4383
+_SHLACC = $438B
+_divHLby10 = $4044
+_divAby10 = $4DAF
+_cphlde = $403C
+_clrWindow = $4A86
+_asapvar = $D6FC
+_MOV4B = $429B ;4x ld (de),(hl)
+_MOV5B = $4297 ;5x ld (de),(hl)
+_mov9b = $4283 ;9x ld (de),(hl)
+_ldHLind = $4010 ;ld hl,(hl)
+_swapt_ = $45F3 ;ex_ahl_bde
;-----------------------------
;------- program start -------
Start:
ld (SpSave),sp
- call _runIndicOff
- call _flushAllMenus
+ call _runindicoff
+ call _flushallmenus
call _clrLCD
res 2,(iy+13) ;appAutoScroll
ld b,a
menukeys:
halt \ halt
- call _getcsc
+ call GET_KEY
or a
jr z,menukeys
cp K_UP
add hl,de
ld a,(hl)
- push af
+ ld d,a ;push af
and _datasingl
jr z,notsingle
ld a,1
ld (nrworms),a
+ ld a,d
+ and _datafoodl
+ jr nz,notsingle
+ ld a,1
+ ld (worm1+lives),a
notsingle:
- pop af
+ ld a,d
ld (gameCar),a
push af
linkmatch:
call _clrWindow
-
-
-; in a,(7)
-; and %11
-; cp %11
ld a,WormVersion
-; jr nz,host
call send
- jr c,host
-
-client:
- ld hl,txtReceive
- call _puts
- call receive
- cp WormVersion
- ret nz
- jr multiplayer
+ jr c,client ;2nd
host:
ld hl,txtWaiting
call _puts
call receive
cp WormVersion
- ret nz
+ jp nz,LinkBreak
call send
+
ld hl,SwapPos
ld (hl),$f6
+ jr multiplayer
+
+client:
+ ld hl,txtReceive
+ call _puts
+ call receive
+ cp WormVersion
+ jp nz,LinkBreak
multiplayer:
ld a,2
ld b,4
worminit:
push bc ; >> 1
- ld a,(de)
- ld (hl),a ;d
- inc de
- inc hl
+ ex de,hl
+ ldi ;d
ld a,SinCosTable/256
- ld (hl),a
- inc hl
-
- ld a,(de)
- ld (hl),a ;y
- inc de
- inc hl
- ld a,(de)
- ld (hl),a ;x
+ ld (de),a
inc de
- inc hl
+ ldi ;y
+ ldi ;x
+ ex de,hl
xor a
ld (hl),a ;y2
ld de,(worm1+score)
HiScore =$+1
ld hl,0
- ld a,e
- cp l
- jr c,NotNewHigh
ld a,d
cp h
jr c,NotNewHigh
+ ld a,e
+ cp l
+ jr c,NotNewHigh
ld (HiScore),de
ex de,hl ;disp.new hiscore
NotNewHigh:
- ex de,hl
+ ex de,hl ;push
+ ld hl,$0807
+ ld (_curRow),hl
ld hl,txthiscore
call _puts
- ex de,hl
+ ex de,hl ;pop
call showHL
hiscorecheckdone:
waitkey:
halt
halt
- call _getcsc
+ call GET_KEY
cp K_ENTER
jp z,DisplayMenu
; cp K_EXIT
call _SET_ABS_SRC_ADDR
ld hl,end-start
call _SET_MM_NUM_BYTES
- call _MM_LDIR
+ call _mm_ldir
; xor a
; ld (_asapvar+1),a
dec d
ret
-;CLEM's FIND_PIXEL (131 cycles; 28 bytes)
-; (b,c) to hl:a; destroyes: -)
+;CLEM's FIND_PIXEL (131+? cycles; 28+4 bytes)
+; (b,c) to hl:a; destroyes: -)
FindPixel:
- ld h,ScrBuffer/$800
- ld a,c
- add a,a
- add a,a
- ld l,a ;hl=4*y + offset/8
- ld a,b
+ ld h,0
+ ld l,c ;hl=y
+ add hl,hl
+ add hl,hl
+ ld a,b ;a=x
rra
add hl,hl
rra
add hl,hl
- add hl,hl ;hl=32*y + offset
+ add hl,hl ;hl=32*y
rra ;a=x/8
or l
ld l,a
xor a
FP_Bit =$+1
set 0,a
+
+ push de
+ ld de,ScrBuffer
+ add hl,de
+ pop de
ret
;----------- score -----------
;-----------------------------
;----------- link ------------
;-----------------------------
-#ifdef 0
-TIMEOUT = $1200
-send:
- push af ;ld b,a
- call _getcsc
- cp K_EXIT
- jp z,Exit
- pop af ;ld a,b
- call SendByte
-; jr c,send
- ret
-
-linkfail:
- jp Exit
-
-LinkPrep:
- ex (sp),hl
- push bc
- push de
- set 2,(iy+$12) ;cursorblink
- ld b,8
- jp (hl)
+TIMEOUT = $1000
receive:
- call checklink
- jr z,linkfail
+ call GET_KEY
+ cp K_EXIT
+ jp z,LinkBreak
+ in a,(7)
+ and %11
cp %11
jr z,receive
-ReceiveByteCont:
- call LinkPrep
+ call Qreceive
+ jr c,receive
+ ret
+
+Qreceive:
+ ld b,8
jr ReceiveCont
-ReceiveByte:
- call LinkPrep
-ReceiveBits:
- ld de,TIMEOUT
+receiveloop:
+ ld de,TIMEOUT
WaitRecBit:
- call checklink
+ call CheckLink
jr z,LinkFailed
cp %11
jr z,WaitRecBit
ReceiveCont:
- sub %10
- ld a,%10
- ld d,D0lD1h
- jr c,ReceiveLow
- rra
- ld d,D0hD1l
+ sub 2
+ ld a,2
+ ld d,D0LD1H
+ jr c,ReceiveLow
+ rra
+ ld d,D0HD1L
ReceiveLow:
- rr c
- ld (AckBit),a
- ld a,d
- out (7),a
- ld de,TIMEOUT
+ rr c
+ ld (AckBit),a
+ ld a,d
+ out (7),a
+ ld de,TIMEOUT
WaitAckRec:
- call checklink
- cp 0
+ call CheckLink
+ cp 0
AckBit =$-1
- jr nz,WaitAckRec
- ld a,D0hD1h
- out (7),a
- ld d,4
+ jr nz,WaitAckRec
+ ld a,D0HD1H
+ out (7),a
+ ld d,4
WaitReadyRec:
- dec d
- jr z,ReadyRec
- in a,(7)
- cp %11
- jr nz,WaitReadyRec
+ dec d
+ jr z,ReadyRec
+ in a,(7)
+ cp %11
+ jr nz,WaitReadyRec
ReadyRec:
- djnz ReceiveBits
- jr LinkSuccess
+ djnz receiveloop
+ jr LinkSuccess
-SendByte:
- call LinkPrep
+send:
+ ld b,9
ld c,a
- inc b
jr SendAcked
SendBits:
rr c
-
-sendbit:
- ld a,D0lD1h
- jr nc,sendselected
- ld a,D0hD1l
-sendselected:
+ ld a,D0LD1H
+ jr nc,SendLow
+ ld a,D0HD1L
+SendLow:
out (7),a
- ld de,TIMEOUT
-waitacknowledge:
- call checklink
- jr nz,waitacknowledge
+ ld de,TIMEOUT
+WaitAckSend:
+ call CheckLink
+ jr nz,WaitAckSend
SendAcked:
- ld a,D0hD1h
+ ld a,D0HD1H
out (7),a
- ld de,TIMEOUT
-waitsendready:
- call checklink
+ ld de,TIMEOUT
+WaitReadySend:
+ call CheckLink
cp %11
- jr nz,waitsendready
-
+ jr nz,WaitReadySend
djnz SendBits
-LinkSuccess: ;nc
- .db $f6 ;first byte of "or n"
-LinkFailed: ;c
- scf
- ld a,c
- res 2,(iy+$12) ;noblink
- pop de
- pop bc
- pop hl
+LinkSuccess:
+ ld a,c ;pop a
ret
-linkerror:
+LinkFailed:
+ scf
+ ld a,c
+ ret
+LinkBreak:
+ ld a,D0HD1H
+ out (7),a
jp Exit
-checklink:
- pop hl
- dec de
- ld a,d
- or e
- jr z,LinkFailed
- ld a,$BF ;key
- call _readkeypad
- bit 6,a
- jr z,linkerror
-
- in a,(7)
- and %11
- jp (hl)
- ret
+CheckLink:
+ pop hl
+ dec de
+ ld a,d
+ or e
+ jr z,LinkFailed
-_readkeypad:
+ ld a,$BF
out (1),a
+ nop \ nop
in a,(1)
push af
ld a,%11111111
out (1),a
pop af
- ret
-#endif
-
-send:
-SendByte:
- in a,(7)
- and %11
- jr z,nolink
- ld b,8
-sendloop:
- ld de,$8000
- rl c
- ld a,%11010100
- jr nc,sendbit
- ld a,%11101000
-sendbit:
- out (7),a
-sendwait1:
- call checklink
- in a,(7)
- and %11
- jr nz,sendwait1
- ld a,%11000000
- out (7),a
-sendwait2:
- call checklink
- in a,(7)
- and %11
- cp %11
- jr nz,sendwait2
- djnz sendloop
- xor a
- ret
-timeout:
- scf
- ret
-
+ bit 6,a
-receive:
- in a,(7)
- and %11
- jr z,nolink
- cp %11
- jr z,receive
- ld b,8
-receiveloop:
- ld de,$8000
-receivewait1:
- call checklink
- in a,(7)
- and %11
- cp %11
- jr z,receivewait1
- rra
- rl c
- rra
- ld a,%11010100
- jr nc,receivebit
- ld a,%11101000
-receivebit:
- out (7),a
-receivewait2:
- call checklink
in a,(7)
and %11
- jr z,receivewait2
- ld a,%11000000
- out (7),a
- djnz receiveloop
- xor a
- ret
+ jp (hl)
-checklink:
- dec de
- ld a,d
- or e
- jr z,timeout
- ld a,$BF ;key
- call _readkeypad
- bit 6,a
- jr z,timeout
- ret
-_readkeypad:
- out (1),a
- in a,(1)
- push af
- ld a,%11111111
- out (1),a
- pop af
- ret
-nolink:
- jp Exit
;-----------------------------
;---------- levels -----------
.db 4,19,16,34
.db 4,19,80,34
+LevelsL:
+ .db 8,0,15,0
+ .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
+ .db 228,157
+ .db 0,0
+
LevelsR:
- .db 8,5,24,0
+ .db 8,2,10,0
.db $40,3,2,$40,6,2, $40,9,2,$40,12,2
.db 128,57
.db 0
LevelsS:
- .db 4,5,10,1 \ .dw $20F
- .db 0,2,63
- .db 128,57
- .db 2
- .db 28,14,100,41
- .db 28,41,100,14
- .db 0
-
.db 5,4,15,0 ;peas,speed,begin_size,balls
- .db 0,2,63 ;d,y,x
- .db 128,57 ;field width, height
- .db 0 ;no additional lines
- .db 0 ;no boxes
+ .db 0,2,63 ;start d, y, x
+ .db 128,57 ;field width (128-255), height (57-255)
+ .db 0,0 ;no additional lines, boxes
.db 8,4,15,0
.db $40,14,2
.db 18,45,110,45
.db 0
+ .db 4,3,10,1 \ .dw $20F
+ .db 0,2,63
+ .db 128,57
+ .db 2
+ .db 28,14,100,41
+ .db 28,41,100,14
+ .db 0
+
.db 7,3,15,0
.db 64,4,0
.db 128,86
.db 110,20,110,64
.db 0
- .db 9,2,15,0
- .db 4,10,$40
+ .db 9,3,15,0
+ .db $40,4,10
.db 128,82
.db 3
.db 0,20,74,20
.db 0,60,74,60
.db 0
- .db 12,2,15,0
- .db 64,4,0
+ .db 12,3,15,0
+ .db $40,4,0
.db 128,90
.db 6
.db 20,16,54,16
.db 0
.db 8,2,15,0
- .db 72,52,$c0
+ .db $C0,72,48
.db 128,128
.db 13
.db 34,56,56,34
gamesdata:
_datalink = %00000001
-_datasingl = %00001000 ;singleplayer=1
_datalivel = %00000010 ;ix+lives=0 limit
_datafoodl = %00000100 ;left=0 limit
_datanextl = %00001000 ;next level if left=0
+_datasingl = %00001000 ;singleplayer=1
_datafood = %00010000 ;food present
_datahunt = %00100000
_datalaps = %01000000 ;give lap score
datafoodm: .db %10010000
.dw LevelsDM
datalinkm: .db %00000011
- .dw LevelsDM
+ .dw LevelsL
datahuntin: .db %10100000
.dw LevelsH
datarace: .db %11000000
.dw LevelsDM
-setdata = 18
resbit = 2 ;and%11111011
worm1set: .dw $B000,$B000 ;%10110000
.db 3,0,%01111110,%10,%100 ;< >
worm2set: .dw $B800,$B800 ;%10111000
.db 3,0,%00111111,%10000,%1000 ;f1 f2
.db "Worm #2",0
-worm3set: .dw $E800,$E800 ;%11101000 ;$D748+$1000+
+worm3set: .dw $F000,$F000 ;$E800=%11101000 ;$D748+$1000+
.db 3,0,%01011111,%10,%100 ;sto ,
.db "Worm #3",0
-worm4set: .dw $F000,$F000 ;%11110000
+worm4set: .dw $A800,$A800 ;$F000=%11110000
.db 3,0,%01111101,%10,%1 ;enter +
.db "Worm #4",0
worm1 = $B400
-worm2 = $B430
-worm3 = $B460
-worm4 = $B490
+worm2 = $B42A
+worm3 = $B454
+worm4 = $B47E ;-A8
end:
;set:
heading = 0 ;level*
Level =$+1
DispBuffer =$+2 ;912 bytes
-ScrBuffer = $8000 ;-$A1FF (32x256)
-SinCosTable = $A200 ;-$A300 (4x64)
+ScrBuffer = $8100 ;-$A2FF (32x256) mod$800=0
+SinCosTable = $B500 ;size=$100 (4x64)
;-----------------------------
;----------- end -------------
;-----------------------------
+ .end
+
.end
\ No newline at end of file