3 ; Release Date : april 2000???
4 ; Filename : worm.86p (4kb)
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 ;-----------------------------
22 ; 2% * make linkplay available for all gametypes (not just deathmatch)
23 ; 1% * fix pea XOR problem in ctf (+dom?)
24 ; 1% * domination?: take control points by running over them and hold them
26 ; * complete readme (+custom level info)
27 ; 2% * ... (pollish, &&&)
31 ;100% = bugs fixed + levels done
33 ;-----------------------------
34 ;-----------------------------
35 ;--------- W O R M ---------
36 ;-----------------------------
37 ;-----------------------------
39 #define buffer ;use display buffer (otherwise write directly to screen)
46 #include "ti86asm.inc"
50 _divHLby10 = $4044 ;hl=hl/10
51 _divAby10 = $4DAF ;a=a/10
52 _HLTIMES10 = $41BF ;hl=hl*10
54 _clrWindow = $4A86 ;clear screen
55 _asapvar = $D6FC ;own name (worm)
56 _MOV4B = $429B ;4x ld (de),(hl)
57 _MOV5B = $4297 ;5x ld (de),(hl)
58 _mov9b = $4283 ;9x ld (de),(hl)
59 _ldHLind = $4010 ;ld hl,(hl)
60 _swapt_ = $45F3 ;ex_ahl_bde
61 _Get_Word_ahl = $521D ;ld de,(ahl)
62 _Set_Word_ahl = $5221 ;ld (ahl),de
63 _INC_PTR_AHL = $4637 ;ahl=ahl+1
64 _AHL_PLUS_2_PG3 = $4C3F ;ahl=ahl+2
65 _SET_ABS_SRC_ADDR = $4647 ;set source for mm.ldir =ahl
66 _LOAD_ABS_SRC_ADDR = $5209 ;ahl = mm.ldir source
67 _SET_ABS_DEST_ADDR = $5285 ;set destination for mm.ldir = ahl
68 _SET_MM_NUM_BYTES = $464F ;number of bytes for mm.ldir = ahl
69 _mm_ldir = $52ED ;24bit ldir
70 _RAM_PAGE_1 = $47E3 ;set $8000+ to page 1
72 _PTEMP_END = $D29A ;end of VAT
73 _load_ram_ahl = $462F ;ahl->page+hl
74 _writeb_inc_ahl = $5567 ;ld (ahl),c
76 ;-----------------------------
77 ;------- data storage -------
78 ;-----------------------------
82 ScrBuffer = $8820 ;-A7FF (20*FF=1FE0)
83 worm2p = $A800 ;-ABFF (400) %10101O00
84 worm1 = $AC00 ;-AC1D (31d)
85 worm2 = $AC1F ;-AC3B (1F)
86 worm3 = $AC3E ;-AC59 (1F)
87 worm4 = $AC5D ;-AC77 (1F)
88 balls = $AC7C ;-ACFF (3x43d)
89 SinCosTable = $AD00 ;-AE00 (4x40)
90 ;free $AE01 ;-AFFF (1FF)
91 worm1p = $B000 ;-B7FF (800) %1011O000
92 worm3p = $B800 ;-BBFF (400) %10111O00
93 ;free $BF91 ;-BFFF (6F)
95 ;program $D748 ;-E7FF (106D+4A)
96 ;free $E800 ;-EFFF (800)
97 worm4p = $F000 ;-F3FF (400) %11110O00
98 leveldata = $F400 ;-FA70 (<=671)
104 templevels = $BC00 ;(3*strings) @init
105 namelength = $BC00 ;(1) @menu
107 DispBuffer = $BC00 ;(10x57d) @game
112 ;-----------------------------
113 ;------- program start -------
114 ;-----------------------------
128 .db "WORM by SHIAR -- pre-beta 90%",0
131 .db %10010110,%01101111
132 .db %10110101,%01001011
133 .db %01110011,%01001001
134 .db %00000011,%10000000
135 .db %00000001,%11100000
136 .db %00111000,%11111000
137 .db %01111110,%00111111
138 .db %11101111,%00001111
139 .db %11000011,%10000000
142 levelhead2 = 90 ;worm levels header = "90"
150 ld hl,$BFFF ;VAT start
153 ld de,(_PTEMP_END+1) ;VAT end
186 ex de,hl ;ld ahl,(hl)
187 cal _AHL_PLUS_2_PG3 ;string id
188 cal _Get_Word_ahl ;ld de,(ahl)
193 jr nz,searchnext ;not worm
211 cal _Get_Word_ahl ;ld de,(ahl++)
216 ld a,e ;set new level
238 jp z,_clrWindow ;no ext files: exit
246 cal _puts ;"< Select levels: >"
265 cal _load_ram_ahl ;hl=ahl
266 ld b,(hl) ;b=title size
268 cal _putps ;destr=abchl
286 cp K_ENTER-K_EXIT+256
298 ld (leveldataSize),de
307 cal _SET_ABS_SRC_ADDR
310 cal _SET_ABS_DEST_ADDR
314 cal _SET_MM_NUM_BYTES
317 cal _LOAD_ABS_SRC_ADDR ;->ahl
323 res 2,(iy+13) ;appAutoScroll
327 ;-----------------------------
328 ;----- build trig tables -----
329 ;-----------------------------
354 ;-----------------------------
355 ;---------- menu -------------
356 ;-----------------------------
391 cal _puts ;Singleplayer
403 jp LetsGetThisPartyOn ;1/3/4
415 jp nz,LetsGetThisPartyOn
423 ld d,(hl) ;max level for sel.game
464 jr dispnrworms ;jr mainMenu
469 jr c,mainMenu ;type 0/1
483 jr dispcurlevel ;mainMenu
532 cal _puts ;"Enter name player "
618 jr nz,waitnokeypressed
622 .db 0,".<>!",0,0,0,0 ;down,L,R,up
623 .db 0,"xtoje0",0 ;enter..clear
624 .db " wsnid9",0 ;(-)..custom
625 .db "zvrmhc8",0 ;dot..del
626 .db "yuqlgb7#" ;0..xvar
627 .db 0,"-pkfa6'" ;on..alpha
628 .db "54321*",0,0 ;F5..more
632 skiplevel: ;@hl - destr:ab - alter:hl
637 ld b,(hl) ;spritesize
648 inc b ;multiplayer lvl
650 inc b ;skip other 3 worms (9 bytes)
661 ld a,(hl) ;lines/boxes
671 ;-----------------------------
672 ;-------- start game ---------
673 ;-----------------------------
677 ld (CheckExit),a ;set exit state
699 ld de,$FF64 ;virt.infinate
705 cal _ldHLind ;ld hl,(hl)
710 dec d ;levels to skip
751 ;-----------------------------
752 ;--------- game over ---------
753 ;-----------------------------
764 ld (worm1+score+1),hl
765 ;+score2=0 \ +delay=1
766 ld (worm2+score+1),hl
767 ld (worm3+score+1),hl
768 ld (worm4+score+1),hl
771 ld a,4 ;4x (all worms)
778 ex de,hl ;de=wormX+head
780 jr nz,createwormsloop
787 pop hl ;begin of current level
802 ;show end msg or smtn
804 psh bc ;where to go afterwards
805 inc hl ;location of ending-code
806 jp (hl) ;go there ("call")
828 ld b,0 ;bc=sprite size
829 add hl,bc ;hl=behind sprite
877 ld bc,(worm2-worm1)-5
882 ;-------- draw level ---------
1001 ;-----------------------------
1003 psh hl ; >> levelp new
1027 ld hl,4+(txtposReady*256)
1037 jr z,SwapPos ;no link
1043 SwapPos: ;$18 xx -> $F6 xx
1051 ld a,(worm1+heading)
1053 ld a,(worm2+heading)
1054 ld (worm1+heading),a
1056 ld (worm2+heading),a
1064 ;-----------------------------
1065 ;----------- LOOP ------------
1066 ;-----------------------------
1085 jr nz,screeninvertloop
1101 cal nz,handlethoseneatlittleballs
1114 ;-----------------------------
1115 ;---------- keys -------------
1116 ;-----------------------------
1131 rla ;=$17 (c=EXIT-key)
1139 ld (ix+delay),respawndelay
1158 ret nz ;HandleWorm done
1162 ld a,$A7 ;exit@end of turn
1163 ld (CheckExit),a ;set exit state
1221 ld a,(hl) ;worm+died
1229 cal _ldHLind ;ld hl,(hl)
1230 cal showHL ;worm+score
1236 dnz displayWormStats
1239 or a ;singleplayer (0) only
1240 jr nz,hilevelcheckdone
1246 jr c,hilevelcheckdone
1247 ld (hl),a ;save local
1252 hilvlposhl =$-2 ;save external
1253 cal _writeb_inc_ahl ;ld (ahl),c
1258 jr z,hiscorecheckdone
1260 cal loadhiscoreposinahl
1261 cal _Get_Word_ahl ;de=old_hi
1269 jr c,NotNewHigh ;New<Old
1270 jr nz,newhigh ;New>Old
1274 jr nc,NotNewHigh ;new<old
1278 cal loadhiscoreposinahl
1279 cal _Set_Word_ahl ;de->(ahl)
1282 NotNewHigh: ;de=current hiscore
1300 ;x123456789012345678901
1301 ;1----- GAME OVER -----
1306 ;6Worm#02 @ 05 00120
1312 rst 20h ;_ABS_MOV10TOOP1
1318 cal _SET_ABS_DEST_ADDR
1322 cal _SET_ABS_SRC_ADDR
1323 ld hl,end-_asm_exec_ram
1324 cal _SET_MM_NUM_BYTES
1331 loadhiscoreposinahl:
1336 externalhiscoresavepos:
1344 dnz addlevelposition
1347 ;-----------------------------
1348 ;----------- worm ------------
1349 ;-----------------------------
1371 inkeys: ;use jp not call!
1390 ld bc,donediddelydone
1401 cal saverespawncounter
1407 jr DoesWormTailEqualsWormHead ;chk4 size=0
1418 DoesWormTailEqualsWormHead:
1420 jr nz,removewormloop
1424 jr nz,safewormsizedone
1432 ld (ix+tail),e ;head=tail/size=0
1438 jr nz,saverespawncounter
1449 ;------- handle worm ---------
1481 ;-------- move worm ----------
1509 notmoveY: ;bc=newpos
1516 pop hl ; << pos (old)
1534 ;--------- worm hit ----------
1540 cal z,checkhitotherworm
1542 and _datamultpeas ;&&bit
1546 jp z,WormDead ;no food
1553 cal DrawPea ;remove pea
1565 jp nz,Drawworm ;continue
1571 jp nz,Exit ;stack restored
1582 cal IncScore ;score+(40*level)
1586 pop hl ; << levelp new
1589 chkpeahit: ;hl=peapos
1618 ld hl,(peaspos) ;1st pea
1624 ld hl,(peaspos+2) ;2nd pea
1627 pop hl ;(peapos) 1st pea
1628 jp c,stopworm ;own pea hit
1630 ld a,e ;peek a (that x86 asm for pop\push ;)
1633 ld hl,(peaspos+2) ;2nd pea
1646 cal DrawPea ;restore own flag
1647 jr sillylabel ;inv both\die
1649 hitflag: ;correct pea hit
1667 ret ;Z=yes: no flag taken
1669 ;-----------------------------
1688 jr nz,nextotherwormbit
1713 .db $dd,$7d ;ld a,lx
1716 jr nz,chkworm2 ; ret nz
1741 ;-------- draw worm ----------
1749 cal z,checkhitlapline
1794 ;-----------------------------
1795 ;---------- ball -------------
1796 ;-----------------------------
1798 handlethoseneatlittleballs:
1844 bit 1,d ;1=up; 0=down
1874 letsmovetheotherway:
1889 ;-----------------------------
1890 ;----------- procs -----------
1891 ;-----------------------------
1936 jr nz,NewPea ;pixel found
1943 ;all ok; empty space
1952 ;----------- score -----------
1972 jr z,scorecommon ;hl/1000 not increased
1980 jr c,showstats ;<0=0
2118 ;-----------------------------
2236 ld (ShiftRightCounter),a
2238 ld (ShiftRightChunk),a
2252 ShiftRightCounter = $-1
2274 ld (ShiftLeftCounter),a
2276 ld (ShiftLeftChunk),a
2278 jr nc,ShiftLeftSameByte
2297 ShiftLeftCounter = $-1
2308 jr nz,ShiftRowsRight
2342 ;----------- draw ------------
2356 CheckPixel: ;at bc in d
2363 ;CLEM's FIND_PIXEL (131+? cycles; 28+4 bytes)
2364 ;(b,c) to hl:a; "destroyes" ahl
2366 FindPixel: ;(b,c) to hl:a
2399 PutSprite: ;||@(b,c)
2400 ;by SHIAR only ix saved
2552 drawbox: ;(d,e)-(h,l)
2562 ;-----------------------------
2563 ;----------- link ------------
2564 ;-----------------------------
2850 ;-----------------------------
2851 ;---------- levels -----------
2852 ;-----------------------------
2855 .db 5,4,15,15,0,0 ;peas,speed,growth,begin_size,sprite,balls
2856 .db 0,2,63 ;start d, y, x
2857 .db 128,57 ;field width (128-255), height (57-255)
2858 .db 0,0 ;no additional lines, boxes
2865 .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
2869 ;-----------------------------
2870 ;---------- data -------------
2871 ;-----------------------------
2874 .db %00011110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
2875 .db %00111110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
2876 .db %01110000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
2877 .db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000
2878 .db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000
2879 .db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000
2880 .db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000
2881 .db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100
2882 .db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100
2883 .db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100
2884 .db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100
2885 .db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001100
2886 .db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00001100
2887 .db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00011100
2888 .db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00011000
2889 .db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00011000
2891 txtMenu: .db "by Shiar",0
2892 .db "Have fun!",0 ;4th menu item
2893 .db "Level 00",0 ;3rd
2894 .db "Worms: 0",0 ;2nd
2895 txtGame: .db "Singleplayer",0 ;0 (1st)
2896 txtGame2: .db "Peaworm ",0 ;1 (next 1st)
2897 .db "Deathmatch",0 ;2
2898 .db "Foodmatch ",0 ;3
2899 .db "LinkMatch",0 ;4
2902 .db "Domination",0 ;7
2903 txtLevsel: .db $CF," Select levels: ",5,0
2904 txtName: .db "Enter name player ",0
2905 txtWaiting: .db "Waiting...",0
2906 txtReceive: .db "Receiving..." ;,0
2909 .db 0, 3, 6, 9, 12, 15, 18, 21
2910 .db 24, 27, 30, 33, 36, 39, 42, 45
2911 .db 48, 51, 54, 57, 59, 62, 65, 67
2912 .db 70, 73, 75, 78, 80, 82, 85, 87
2913 .db 89, 91, 94, 96, 98,100,102,103
2914 .db 105,107,108,110,112,113,114,116
2915 .db 117,118,119,120,121,122,123,123
2916 .db 124,125,125,126,126,126,126,126
2919 txtLevel: .db "Level ",0
2920 txtWorms: .db "Worms: 0",0 ;follows txtLevel
2921 txtDied: .db "Died ",0
2922 txtScore: .db "Score",0 ;follows txtDied
2923 txtLeft: .db " left",0 ;follows txtScore
2924 txthiscore:.db "HiScore:",0
2925 txtReady: .db "Prepare!",0
2927 txtGO: .db "----- GAME OVER -----",0
2931 _datalink = %00000001 ;linkplay
2932 _datalivel = %00000010 ;lives=0 limit
2933 _datafoodl = %00000100 ;left=0 limit
2934 _datanextl = %00001000 ;next level if left=0
2935 _datasingl = %00001000 ;singleplayer=1
2936 _datafood = %00010000 ;food present
2937 _________ = %00100000 ;
2938 _datadie = %01000000 ;worm dies on impact
2939 _datascore = %10000000 ;score>=100 limit
2940 _datamultpeas = %00100000
2943 datasingle: .db %01011110
2945 datapeas: .db %01011010
2947 datadeathm: .db %01000010
2949 datafoodm: .db %11010000
2951 datalinkm: .db %01000011
2953 datarace: .db %10000000
2955 datactf: .db %11100000
2957 datadomin: .db %01000000 ;==(8 modes)
2959 datalevels: .dw LevelDef, LevelDef
2960 .dw LevelDefM,LevelDefM
2961 .dw LevelDefM,LevelDefM
2962 .dw LevelDefM,LevelDefM
2963 nrlevels: .db 2,2,2,2,2,2,2,2
2965 worm1set: .dw worm1p,worm1p
2966 .db %11110111,3,%00,%01111110,%10,%100 ;< >
2967 worm1name: .db "worm #01",0
2968 worm2set: .dw worm2p,worm2p
2969 .db %11111011,3,%11,%00111111,%10000,%1000 ;f1 f2
2970 worm2name: .db "worm #02",0
2971 worm3set: .dw worm3p,worm3p
2972 .db %11111011,3,0,%01011111,%10,%100 ;sto ,
2973 worm3name: .db "worm #03",0
2974 worm4set: .dw worm4p,worm4p
2975 .db %11111011,3,0,%01111101,%10,%1 ;enter +
2976 worm4name: .db "worm #04",0
2982 peasprite: .db %01100000
2996 head = 12 ;4B (head=tail)
2997 tail = 14 ;also@next level
3012 ;-----------------------------
3013 ;----------- end -------------
3014 ;-----------------------------