3 ; Release Date : may 2000
4 ; Filename : worm.86p (5kb)
6 ; Email Address : shiar@mailroom.com
8 ; Web Page : www.games3.net/shiar
9 ; Description : ruling multiplayer game for 86 (most like Nibbles)
10 ; Where to get this game : games3.net/shiar (home of Worm)
11 ; Other games by author(s) : Shiar: Nemesis beta
12 ; Additional Credits to : Matthew Shepcar (wrote original Peaworm, end'98)
13 ; Jonah Cohen (wrote some parts of worm)
15 ;-----------------------------
16 ;----------- TO-DO -----------
17 ;-----------------------------
21 ; 2% * fix deaths linkplay and transmit game/level data
22 ; 2% * make linkplay available for all gametypes (not just deathmatch)
23 ; 1% * fix pea XOR problem in ctf (+dom?)
25 ; 1% * domination?: take control points by running over them and hold them
27 ; * complete readme (+custom level info)
28 ; 2% * ... (pollish, &&&)
32 ;100% = bugs fixed + levels done
34 ;-----------------------------
35 ;-----------------------------
36 ;--------- W O R M ---------
37 ;-----------------------------
38 ;-----------------------------
40 #define buffer ;use display buffer (otherwise write directly to screen)
41 #define readymask ;"grays" out the field before starting a level
43 ;#define readytext ;displays "prepare" before level starts
44 ;#define invincible ;worms cannot die =)
51 #include "ti86asm.inc"
55 _divHLby10 = $4044 ;hl=hl/10
56 _divAby10 = $4DAF ;a=a/10
57 _HLTIMES10 = $41BF ;hl=hl*10
59 _clrWindow = $4A86 ;clear screen
60 _asapvar = $D6FC ;own name (worm)
61 _MOV4B = $429B ;4x ld (de),(hl)
62 _MOV5B = $4297 ;5x ld (de),(hl)
63 _mov9b = $4283 ;9x ld (de),(hl)
64 _ldHLind = $4010 ;ld hl,(hl)
65 _swapt_ = $45F3 ;ex_ahl_bde
66 _Get_Word_ahl = $521D ;ld de,(ahl)
67 _Set_Word_ahl = $5221 ;ld (ahl),de
68 _INC_PTR_AHL = $4637 ;ahl=ahl+1
69 _AHL_PLUS_2_PG3 = $4C3F ;ahl=ahl+2
70 _SET_ABS_SRC_ADDR = $4647 ;set source for mm.ldir =ahl
71 _LOAD_ABS_SRC_ADDR = $5209 ;ahl = mm.ldir source
72 _SET_ABS_DEST_ADDR = $5285 ;set destination for mm.ldir = ahl
73 _SET_MM_NUM_BYTES = $464F ;number of bytes for mm.ldir = ahl
74 _mm_ldir = $52ED ;24bit ldir
75 _RAM_PAGE_1 = $47E3 ;set $8000+ to page 1
77 _PTEMP_END = $D29A ;end of VAT
78 _load_ram_ahl = $462F ;ahl->page+hl
79 _writeb_inc_ahl = $5567 ;ld (ahl),c
80 _jforce = $409C ;TI-OS stack restored
82 ;-----------------------------
83 ;------- data storage -------
84 ;-----------------------------
88 ScrBuffer = $8820 ;-A7FF (20*FF=1FE0)
89 worm2p = $A800 ;-ABFF (400) %10101O00
90 worm1 = $AC00 ;-AC1D (31d)
91 worm2 = $AC1F ;-AC3B (1F)
92 worm3 = $AC3E ;-AC59 (1F)
93 worm4 = $AC5D ;-AC77 (1F)
94 balls = $AC7C ;-ACFF (3x43d)
95 SinCosTable = $AD00 ;-AE00 (4x40)
96 ;free $AE01 ;-AFFF (1FF)
97 worm1p = $B000 ;-B7FF (800) %1011O000
98 worm3p = $B800 ;-BBFF (400) %10111O00
99 ;free $BF91 ;-BFFF (6F)
101 ;program $D748 ;-E7FF (106D+4A)
102 ;free $E800 ;-EFFF (800)
103 worm4p = $F000 ;-F3FF (400) %11110O00
104 leveldata = $F400 ;-FA70 (<=671)
110 templevels = $BC00 ;(3*strings) @init
111 namelength = $BC00 ;(1) @menu
113 DispBuffer = $BC00 ;(10x57d) @game
118 ;-----------------------------
119 ;------- program start -------
120 ;-----------------------------
134 .db "WORM by SHIAR -- pre-beta 91%",0
137 .db %10010110,%01101111
138 .db %10110101,%01001011
139 .db %01110011,%01001001
140 .db %00000011,%10000000
141 .db %00000001,%11100000
142 .db %00111000,%11111000
143 .db %01111110,%00111111
144 .db %11101111,%00001111
145 .db %11000011,%10000000
148 levelhead2 = 91 ;worm levels header = "91"
156 ld hl,$BFFF ;VAT start
159 ld de,(_PTEMP_END+1) ;VAT end
192 ex de,hl ;ld ahl,(hl)
193 cal _AHL_PLUS_2_PG3 ;string id
194 cal _Get_Word_ahl ;ld de,(ahl)
199 jr nz,searchnext ;not worm
217 cal _Get_Word_ahl ;ld de,(ahl++)
222 ld a,e ;set new level
244 jp z,_clrWindow ;no ext files: exit
252 cal _puts ;"< Select levels: >"
271 cal _load_ram_ahl ;hl=ahl
272 ld b,(hl) ;b=title size
274 cal _putps ;destr=abchl
292 cp K_ENTER-K_EXIT+256
304 ld (leveldataSize),de
313 cal _SET_ABS_SRC_ADDR
316 cal _SET_ABS_DEST_ADDR
320 cal _SET_MM_NUM_BYTES
323 cal _LOAD_ABS_SRC_ADDR ;->ahl
329 res 2,(iy+13) ;appAutoScroll
333 ;-----------------------------
334 ;----- build trig tables -----
335 ;-----------------------------
360 ;-----------------------------
361 ;---------- menu -------------
362 ;-----------------------------
390 cal _puts ;Level <00>
397 cal _puts ;Singleplayer
409 jp LetsGetThisPartyOn ;1/3/4
423 jp nz,LetsGetThisPartyOn
431 ld d,(hl) ;max level for sel.game
485 jr dispnrworms ;mainMenu
490 jr c,_mainMenu ;type 0/1
499 ld a,(hl) ;hl=nrworms
506 jr _dispcurlevel ;mainMenu
563 cal _puts ;"Enter name player "
654 jr nz,waitnokeypressed
658 .db 0,".<>!",0,0,0,0 ;down,L,R,up
659 .db 0,"XTOJE0",0 ;enter..clear
660 .db " WSNID9",0 ;(-)..custom
661 .db "ZVRMHC8",0 ;dot..del
662 .db "YUQLGB7#" ;0..xvar
663 .db $D9,"-PKFA6'" ;on..alpha
664 .db "54321*",0,$D0 ;F5..more
668 skiplevel: ;@hl - destr:ab - alter:hl
673 ld b,(hl) ;spritesize
684 inc b ;multiplayer lvl
686 inc b ;skip other 3 worms (9 bytes)
708 ld a,(hl) ;lines/boxes
719 ;-----------------------------
720 ;-------- start game ---------
721 ;-----------------------------
725 ld (CheckExit),a ;set exit state
747 ld de,$FF64 ;virt.infinate
753 cal _ldHLind ;ld hl,(hl)
758 dec d ;levels to skip
803 ;-----------------------------
804 ;--------- game over ---------
805 ;-----------------------------
816 ld (worm1+score+1),hl
817 ;+score2=0 \ +delay=1
818 ld (worm2+score+1),hl
819 ld (worm3+score+1),hl
820 ld (worm4+score+1),hl
823 ld a,4 ;4x (all worms)
830 ex de,hl ;de=wormX+head
832 jr nz,createwormsloop
839 pop hl ;begin of current level
854 ;show end msg or smtn
856 psh bc ;where to go afterwards
857 inc hl ;location of ending-code
858 jp (hl) ;go there ("call")
880 ld b,0 ;bc=sprite size
881 add hl,bc ;hl=behind sprite
931 ld bc,(worm2-worm1)-5
936 ;-------- draw level ---------
1067 ;-----------------------------
1069 psh hl ; >> levelp new
1104 ld hl,4+(txtposReady*256)
1115 jr z,SwapPos ;no link
1121 SwapPos: ;$18 xx -> $F6 xx
1129 ld a,(worm1+heading)
1131 ld a,(worm2+heading)
1132 ld (worm1+heading),a
1134 ld (worm2+heading),a
1143 ;-----------------------------
1144 ;----------- LOOP ------------
1145 ;-----------------------------
1164 jr nz,screeninvertloop
1180 cal nz,handlethoseneatlittleballs
1193 ;-----------------------------
1194 ;---------- keys -------------
1195 ;-----------------------------
1210 rla ;=$17 (c=EXIT-key)
1221 ld (ix+delay),respawndelay
1240 ret nz ;HandleWorm done
1244 ld a,$A7 ;exit@end of turn
1245 ld (CheckExit),a ;set exit state
1279 cp (hl) ;input=0 = link
1304 ld a,(hl) ;worm+died
1312 cal _ldHLind ;ld hl,(hl)
1313 cal showHL ;worm+score
1319 dnz displayWormStats
1322 or a ;singleplayer (0) only
1323 jr nz,hilevelcheckdone
1328 jr c,hilevelcheckdone
1329 ld (hl),a ;save local
1334 hilvlposhl =$-2 ;save external
1335 cal _writeb_inc_ahl ;ld (ahl),c
1340 jr z,hiscorecheckdone
1342 cal loadhiscoreposinahl
1343 cal _Get_Word_ahl ;de=old_hi
1351 jr c,NotNewHigh ;New<Old
1352 jr nz,newhigh ;New>Old
1356 jr nc,NotNewHigh ;new<old
1360 cal loadhiscoreposinahl
1361 cal _Set_Word_ahl ;de->(ahl)
1364 NotNewHigh: ;de=current hiscore
1385 ;x123456789012345678901
1386 ;1----- GAME OVER -----
1391 ;6Worm#02 @ 05 00120
1397 rst 20h ;_ABS_MOV10TOOP1
1403 cal _SET_ABS_DEST_ADDR
1407 cal _SET_ABS_SRC_ADDR
1408 ld hl,end-_asm_exec_ram
1409 cal _SET_MM_NUM_BYTES
1417 loadhiscoreposinahl:
1422 externalhiscoresavepos:
1430 dnz addlevelposition
1433 ;-----------------------------
1434 ;----------- worm ------------
1435 ;-----------------------------
1440 cal saverespawncounter
1446 jr DoesWormTailEqualsWormHead ;chk4 size=0
1457 DoesWormTailEqualsWormHead:
1459 jr nz,removewormloop
1463 jr nz,safewormsizedone
1471 ld (ix+tail),e ;head=tail/size=0
1478 jr nz,saverespawncounter
1493 inkeys: ;use jp not call!
1536 ;------- handle worm ---------
1568 ;-------- move worm ----------
1596 notmoveY: ;bc=newpos
1603 pop hl ; << pos (old)
1621 ;--------- worm hit ----------
1627 cal z,checkhitotherworm
1629 and _datamultpeas ;&&bit
1633 jp z,WormDead ;no food
1640 cal DrawPea ;remove pea
1652 jp nz,Drawworm ;continue
1658 jp nz,Exit ;stack restored
1669 cal IncScore ;score+(40*level)
1673 pop hl ; << levelp new
1676 chkpeahit: ;hl=peapos
1705 ld hl,(peaspos) ;1st pea
1711 ld hl,(peaspos+2) ;2nd pea
1714 pop hl ;(peapos) 1st pea
1715 jp c,stopworm ;own pea hit
1717 ld a,e ;peek a (that x86 asm for pop\push ;)
1720 ld hl,(peaspos+2) ;2nd pea
1733 cal DrawPea ;restore own flag
1734 jr sillylabel ;inv both\die
1736 hitflag: ;correct pea hit
1754 ret ;Z=yes: no flag taken
1756 ;-----------------------------
1775 jr nz,nextotherwormbit
1800 .db $dd,$7d ;ld a,lx
1803 jr nz,chkworm2 ; ret nz
1828 ;-------- draw worm ----------
1836 cal z,checkhitlapline
1881 ;-----------------------------
1882 ;---------- ball -------------
1883 ;-----------------------------
1885 handlethoseneatlittleballs:
1931 bit 1,d ;1=up; 0=down
1961 letsmovetheotherway:
1976 ;-----------------------------
1977 ;----------- procs -----------
1978 ;-----------------------------
1982 ld a,%10000000 ;all key-masks
1985 inc a ;cp %11111111 (no keys pressed)
1986 jr nz,releasekeys ;keep waitin
1987 cal GET_KEY ;clear buffer
2033 jr nz,NewPea ;pixel found
2040 ;all ok; empty space
2049 ;----------- score -----------
2069 jr z,scorecommon ;hl/1000 not increased
2077 jr c,showstats ;<0=0
2215 ;-----------------------------
2333 ld (ShiftRightCounter),a
2335 ld (ShiftRightChunk),a
2349 ShiftRightCounter = $-1
2371 ld (ShiftLeftCounter),a
2373 ld (ShiftLeftChunk),a
2375 jr nc,ShiftLeftSameByte
2394 ShiftLeftCounter = $-1
2405 jr nz,ShiftRowsRight
2439 ;----------- draw ------------
2453 CheckPixel: ;at bc in d
2460 ;CLEM's FIND_PIXEL (131+? cycles; 28+4 bytes)
2461 ;(b,c) to hl:a; "destroyes" ahl
2463 FindPixel: ;(b,c) to hl:a
2496 PutSprite: ;||@(b,c)
2497 ;by SHIAR only ix saved
2649 drawbox: ;(d,e)-(h,l)
2659 ;-----------------------------
2660 ;----------- link ------------
2661 ;-----------------------------
2756 .db $F6 ;or NN (skip scf)
2784 ;-----------------------------
2785 ;---------- levels -----------
2786 ;-----------------------------
2789 .db 5,4,15,15,0,0 ;peas,speed,growth,begin_size,sprite,balls
2790 .db 0,2,63 ;start d, y, x
2791 .db 128,57 ;field width (128-255), height (57-255)
2792 .db 0,0 ;no additional lines, boxes
2799 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
2803 ;-----------------------------
2804 ;---------- data -------------
2805 ;-----------------------------
2808 .db %00011110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
2809 .db %00111110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
2810 .db %01110000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
2811 .db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000
2812 .db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000
2813 .db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000
2814 .db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000
2815 .db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100
2816 .db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100
2817 .db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100
2818 .db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100
2819 .db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001100
2820 .db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00001100
2821 .db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00011100
2822 .db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00011000
2823 .db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00011000
2825 txtMenu: .db "by Shiar",0
2826 .db "Have fun!",0 ;4th menu item
2827 .db "Level ",$CF,"??",5,0 ;3rd
2828 .db "Worms ",$CF,"?",5,0 ;2nd
2829 txtGame: .db "Singleplayer",0 ;0 (1st)
2830 txtGame2: .db "Peaworm ",0 ;1 (next 1st)
2831 .db "Deathmatch",0 ;2
2832 .db "Foodmatch ",0 ;3
2833 .db "LinkMatch",0 ;4
2836 .db "Domination",0 ;7
2837 txtLevsel: .db $CF," Select levels: ",5,0
2838 txtName: .db "Enter name player ",0
2839 txtWaiting: .db "Waiting...",0
2840 txtReceive: .db "Receiving..." ;,0
2843 .db 0, 3, 6, 9, 12, 15, 18, 21
2844 .db 24, 27, 30, 33, 36, 39, 42, 45
2845 .db 48, 51, 54, 57, 59, 62, 65, 67
2846 .db 70, 73, 75, 78, 80, 82, 85, 87
2847 .db 89, 91, 94, 96, 98,100,102,103
2848 .db 105,107,108,110,112,113,114,116
2849 .db 117,118,119,120,121,122,123,123
2850 .db 124,125,125,126,126,126,126,126
2853 txtLevel: .db "Level ",0
2854 txtWorms: .db "Worms: 0",0 ;follows txtLevel
2855 txtDied: .db "Died ",0
2856 txtScore: .db "Score",0 ;follows txtDied
2857 txtLeft: .db " left",0 ;follows txtScore
2858 txthiscore:.db "HiScore:",0
2859 txtReady: .db "Prepare!",0
2861 txtGO: .db "----- GAME OVER -----",0
2865 _datalink = %00000001 ;linkplay
2866 _datalivel = %00000010 ;lives=0 limit
2867 _datafoodl = %00000100 ;left=0 limit
2868 _datanextl = %00001000 ;next level if left=0
2869 _datasingl = %00001000 ;singleplayer=1
2870 _datafood = %00010000 ;food present
2871 _________ = %00100000 ;
2872 _datadie = %01000000 ;worm dies on impact
2873 _datascore = %10000000 ;score>=100 limit
2874 _datamultpeas = %00100000
2877 datasingle: .db %01011110
2879 datapeas: .db %01011010
2881 datadeathm: .db %01000010
2883 datafoodm: .db %11010000
2885 datalinkm: .db %01000011
2887 datarace: .db %10000000
2889 datactf: .db %11100000
2891 datadomin: .db %01000000 ;==(8 modes)
2893 datalevels: .dw LevelDef, LevelDef
2894 .dw LevelDefM,LevelDefM
2895 .dw LevelDefM,LevelDefM
2896 .dw LevelDefM,LevelDefM
2897 nrlevels: .db 2,2,2,2,2,2,2,2
2899 worm1set: .dw worm1p,worm1p
2900 .db %11110111,3,%00,%01111110,%10,%100 ;< >
2901 worm1name: .db "worm #01",0
2902 worm2set: .dw worm2p,worm2p
2903 .db %11111011,3,%11,%00111111,%10000,%1000 ;f1 f2
2904 worm2name: .db "worm #02",0
2905 worm3set: .dw worm3p,worm3p
2906 .db %11111011,3,0,%01011111,%10,%100 ;sto ,
2907 worm3name: .db "worm #03",0
2908 worm4set: .dw worm4p,worm4p
2909 .db %11111011,3,0,%01111101,%10,%1 ;enter +
2910 worm4name: .db "worm #04",0
2916 peasprite: .db %01100000
2930 head = 12 ;4B (head=tail)
2931 tail = 14 ;also@next level
2947 ;-----------------------------
2948 ;----------- end -------------
2949 ;-----------------------------