1 ;------------------------------------------------------------------------------
2 ;---------------------- NEMESIS -----------------------------------------------
3 ;------------------------------------------------------------------------------
4 ; >>> NEMESIS <<< Version 0.96 BETA by SHIAR
5 ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8 ; Release Date : 30.X.99
9 ; Filename : nemesis.86p (4836) nemesis0.86p (888)
11 ; Email Address : shiar0@hotmail.com
13 ; Web Page : come.to/shiar
14 ; Description : cool arcade-shoot-em-up-game (release 12/99)
15 ; Where to get this game : www.ticalc.org
16 ; Other games by author : N/A
18 ; ABOUT: This source should only be used for learning practises, do not
19 ; alter it, and certainly do not distribute an altered version!!
20 ; NOTE: &&& marks uncertainties or things to optimize
22 ;---------------------- nemesis.z80 start -------------------------------------
25 #include "ti86asm.inc" ;standard ti86 romcalls
26 #include "ti86abs.inc" ;used to save hiscores and so
30 #define cal call ;just to make it harder for you to understand
31 #define psh push ; ^:D
32 #define dnz djnz ;Dec&Jump while NonZero becomes Do w.Non-Zero
34 TEXT_MEM = _textShadow ;167 bytes ($A7): C0F9-C1A0
35 _clrWindow = $4a86 ;a new procedure from AsmStudio86 inc. files
41 storepos = _asm_exec_ram+6000 ;120 OF 165
42 storepos2 = _asm_exec_ram+6200 ;141 OF 167
43 exlevel = _asm_exec_ram+6400 ;784+OF 2.7kb
45 XLlevelsdata = exlevel+8 ;size: upto 1016 bytes
46 XLweapondata = exlevel+1024 ;size: always 64 byte
47 XLenemytable = exlevel+1088 ;size: always 16 byt
48 XLenemyinfos = exlevel+1104 ;size: always 64 by
49 XLsprenemies = exlevel+1168 ;size: like 128 b (upto 1kb)
51 ;---------------------- in-game vars ------------------------------------------
53 temp1 = storepos ;+0+1 ;temp (2 bytes) bullet
55 just_fired = storepos+2 ; +2 ;counts how long a blast lasts
56 curline = storepos+2 ; +2 ;used to display SFX
57 menuitem = storepos+2 ; +2 ;used to store menu location
58 hiscorepos = storepos+2 ; +2
59 RanPos = storepos+3 ; +3 ;used for making random values
60 timer = storepos+4 ; +4 ;frame counter
62 x = storepos+5 ; +5 ;your ship's position
63 y = x+1 ; +6 ;your y-pos
64 firex = y+1 ; +7 ;(1 byte)
65 firey = firex+1 ; +8 ;(1 byte)
68 eventtime = storepos+10 ;+10 ;enemy frequency
69 eventleft = eventtime+1 ;+11 ;nr. of enemies still to come
70 nextevent = eventleft+1 ;+12 ;time to next event
71 level_enemy = nextevent+1 ;+13 ;enemy type
72 level_info = level_enemy+1 ;+14 ;info (see below)
73 level_move = level_info+1 ;+15 ;=
74 level_fire = level_move+1 ;+16
77 spacespace = storepos+19 ;+19
78 groundinfo = spacespace+1 ;+20
79 groundpos = groundinfo+1 ;+21 $10
80 ceilingpos = groundpos+16 ;+37 $10
82 stars1 = ceilingpos+16 ;+53
83 stars2 = stars1+1 ;+54
85 starx1 = storepos+55 ;+55
87 starx2 = starx1+(nrstars1*2) ;+69
88 ; ^^ ;--------MULTIPLES
89 mx = starx2+(nrstars2*2) ;+83 ;position of multiple#1
90 my = mx+1 ;+84 ;multiple y-pos
93 your_locpos = m2y+1 ;+87 ;position in your_prevpos tabl
94 your_prevpos = your_locpos+1 ;+88 ;save previous positions (32d)
96 ;^-----------------------------------<1 ;-120=$78
98 nrenemies = 10 ;max. nr of enemies
100 enemies = storepos2 ; +0 ;info about each enemy (6byt)
103 ybullets = enemies+(nrenemies*6) ;+80 ;60 bytes = 20(state,x,y)
105 ebullets = ybullets+(nrybuls*3) ;+110 ;30 bytes = 10(state,x,y)
107 ybuls = ebullets+(nrebuls*3) ;+140
109 ;^-----------------------------------<2 ;-141=$8D
111 ; [0000:damage 0:directfire 0:ground 0:ceiling 0:diagfire]
113 ; [000000:HP left 00:(00=no enemy 01=exploding 10=normal 11=moving)]
114 ; [ship type or explosion frame] [x] [y] [move] [fire]
116 ;---------------------- introduction ------------------------------------------
118 nop ;hello yas/ase/rascall/whathever
119 jp init ;here's the program, but first: a description
120 .dw $0001 ;description type 2 (description + YASicon)
121 .dw Title ;pointer to description (all shells)
122 .dw Icon ;pointer to YAS icon
124 Title: .db "Nemesis v0.96 by Shiar",0
126 Icon: .db 8,1 ;icon for YAS: width = 1byte; height = 9bytes
129 .db %00111110 ; █████
130 .db %01111001 ; ████ █
131 .db %00111110 ; █████
133 .db %11100000 ; ███ ;recommend 80x50 screen mode
134 .DB 0 ;clear stupid YAS-line
136 ;---------------------- init --------------------------------------------------
138 level_name: .db 8,"nemesis0"
149 ld bc,int_end-int_handler
166 init: cal BUSY_OFF ;turns the run-indicator off, obviously
167 cal _clrScrn ;clean the screen
170 ld hl,level_name-1 ;find own variable
171 rst 20h ;cal _ABS_MOV10TOOP1
172 rst 10h ;cal _FINDSYM
173 ret c ;not found? who cares...
176 cal _SET_ABS_SRC_ADDR
179 cal _SET_ABS_DEST_ADDR
181 cal _SET_MM_NUM_BYTES
185 cal _SET_MM_NUM_BYTES
190 cal _SET_ABS_DEST_ADDR
192 cal _SET_MM_NUM_BYTES
193 cal _mm_ldir ;save done (cal \ ret)
195 setup: xor a ;<ld a,0>: reset:
196 ld (iy+13),a ;don't affect TEXT_MEM and don't scroll screen
197 ld (_asapvar+1),a ;Asm( thinks it's the first time it runs Nems.
200 ld a,(CONTRAST) ;load current contrast level
201 cp $1f ;if already at maximum...
202 jr z,skipdarken ;...then skip level increase
203 inc a ;otherwise increase contrast level
207 ;---------------------- main menu ---------------------------------------------
210 xor a ;white bitmask (a=0)
212 ld hl,logo_nemesis ;from...
213 ld de,VIDEO_MEM+16 ;...to one line from top
215 ld (de),a ;clear/n byte
217 dnz AboveLogo ;repeat for the first line
219 ld bc,16*19 ;logo size
220 ldir ;display one line of logo
222 ; ld hl,GRAPH_MEM ;cleared line
223 ; ld bc,16 ;size=one line
224 ; ldir ;also clear one line below the logo
226 ; ld a,-1 ;first line is -1+1=0
227 ; ld b,21 ;with first 21 lines:
228 ; cal DoSFX ;do special effect &&&skip
230 ld hl,VIDEO_MEM+(16*$39)+4 ;$39 rows down, 4 cols right (4*8=$20)
231 ld b,8 ;draw 8x one byte = 8*8 = 64 pixels wide
232 ld a,%11111111 ;horizontal line mask
234 ld (hl),a ;draw one piece of the divider-line
235 inc hl ;move right (8 pixels = 1 byte)
236 dnz underline ;repeat
238 set 3,(iy+5) ;set white on black
239 ld hl,$3320 ;near the bottom of the screen
241 ld hl,txt_about ;display version and author (yes, that's me!)
242 cal _vputs ;useful procedure if you want to display somtn
243 res 3,(iy+5) ;return to default black on white
245 ld hl,$3a1e ;below previous stuff
247 ld hl,txt_email ;hey, my e-mail address so SEND ME SOMETHING!!
248 cal _vputs ;VERY important, so display in small font ?:}
283 halt \ halt \ halt \ halt
285 cal GET_KEY ;wait for keypress
323 ;------------------------------------------------------------------------------
324 ;---------------------- game loop ---------------------------------------------
325 ;------------------------------------------------------------------------------
327 game_main_loop: ;REPEATS FROM HERE EVERY FRAME
328 ld hl,timer ;update time
329 inc (hl) ;increase by 1
330 ld b,(hl) ;new time, save for rand# upd. (no flag change)
331 jr nz,updaterandom ;continue when new time <> 0
332 ld hl,1 ;once every 256 frames, increase score by 1
336 ld hl,RanPos ;random counter
337 ld a,r ;add r register to randomize
338 add a,(hl) ;add previous random value
339 add a,b ;even more random by adding timer
340 ld (hl),a ;save even more random value back
343 ld hl,GRAPH_MEM ;move from (hl) = top left
344 ld (hl),$00 ;first pixel will be copied all over the screen
345 ld de,GRAPH_MEM+1 ;(de) = next pixel, thus clearing whole screen
346 ld bc,896 ;loop 896 times = (128/8) * (64-8 for scorebar)
351 jr z,movestarsdone ;don't move stars once every 4 frames
353 cal movestars1 ;move the stars on the FRONT layer
354 cal movestars2 ;move the distant stars
357 ld a,(stars1) ;star positions (the missing byte...)
358 ld b,nrstars1 ;how many stars? now we know.
359 ld hl,starx1 ;points to the position of the stars
360 cal DisplayStars ;display front layer stars
362 ld a,(stars2) ;weren't you paying attention five lines ago?
363 ld b,nrstars2 ;that many?! whow!
364 ld hl,starx2 ;and there they are
365 cal DisplayStars ;use the same procedure to display back layer
367 ld a,(level_info) ;level info
368 and %00000110 ;isolate ground&ceiling
369 jr z,game_stuff ;both non-present
370 and %00000010 ;bit representing the presence of any ceiling
371 cal nz,Handle_ceiling ;scroll the ceiling (if any)
372 cal Handle_ground ;scroll the ground
375 ld a,(your_occ) ;are you 100% OK?
377 jr nz,_gamestuff1 ;then don't check for movements/fires/...
379 ld a,(level_info) ;the same level info
380 and %00000110 ;isolate ground&ceiling again
381 jr z,check_keys ;no ceiling nor ground
382 and %00000010 ;this bit will tell us if there is a ceiling
383 cal nz,CheckCeiling ;if there is, check it
384 cal CheckGround ;check for collision with the ground
391 ld a,%00111111 ;function keys (MORE,EXIT,2ND,F1,F2,F3,F4,F5)
392 out (1),a ;ask for them
393 nop \ nop ;delay 8 clocks
397 bit 6,a ;test bit 6 = exit-key = EXIT
398 jp z,game_over_nopop ;<exit> pressed, so be it
399 check_morekey: ;another unused label... poor compiler
400 bit 7,a ;test bit 7 = more-key = PAUSE
401 cal z,Pause ;yes, go to pause
404 bit 5,a ;test bit 5 = 2nd-key = FIRE
405 ld hl,check_selkey ;where to continue after executing Fire_bullet
406 psh hl ;push hl on stack (instead of cal Fire_bullet)
407 jp z,Fire_bullet ;fire smtn (bulletstorplasermultiples+stuff..)
408 pop hl ;no cal to Fire_bullet made, so pop stack
409 ld hl,just_fired ;no:
410 ld (hl),0 ;reset just_fired
413 ld a,%01011111 ;look at first column of keys (ALPHA to STO)
415 nop \ nop ;what's taking you so long
416 in a,(1) ;at last... our precious keyzzz...
417 ;old: <bit 7,a \ cal z,select> now see this:
418 rla ;test bit7 so we know f ALPHA has been pressed
419 cal nc,select ;yeppy, select the currently selected upgrade
421 cal Enemies_hit ;check for collision with enemies
424 cal Handle_Ship ;move you
425 cal Handle_bullets ;move your bullets
426 cal Handle_torp ;move your torpedo
428 cal Handle_enemies ;move enemies
429 cal Enemy_bullets ;move enemy bullets
431 cal Level_event ;insert enemies
432 cal Display_Screen ;display all
435 jp game_main_loop ;LOOP
437 ;--------------------------- ground -------------------------------------------
441 and %111 ;once every 8 frames
442 jr nz,Display_ground ;otherwise skip the scroll
443 ld bc,15 ;scroll all 16 bytes minus one (teh new byte)
444 ld hl,groundpos+1 ;from..
445 ld de,groundpos ;to (one byte to the left)
446 ldir ;LoaDIncreaseRepeat = scroll!
448 ld a,(groundinfo) ;what kind of ground
450 jr z,ground_tunnel ;tunnel effect
467 jr z,ground_previous ;a>=0 (a=0 actually)
480 ld a,(groundpos+14) ;type 1
483 ld a,(groundpos) ;type 0
485 ld (groundpos+15),a ;save new byte on the right
495 ld b,16 ;screen width
496 ld de,groundpos-1 ;height of current byte (previous actually)
498 ld hl,GRAPH_MEM+(56*16)-1 ;screen position
502 ld c,b ;push b for groundloopup
503 pop hl \ inc hl ;get screen position and go one right
504 pop de \ inc de ;get height info and set to the next byte
505 psh de \ psh hl ;save these for the next time
506 ld a,(de) ;height of current byte
509 ld de,16 ;to substract to go one line up
510 ld a,%11111111 ;bitmask black
513 ld (hl),a ;display black byte
514 sbc hl,de ;go up (sbc must be used for 16-bit sub)
515 dnz groundloopup ;and loop >groundpos< times
517 ld b,c ;pop b used by groundloopup
518 dnz groundloopright ;loop right for entire screen (16x)
519 pop hl \ pop hl ;restore stack
522 CheckGround: ;check for collision with the ground
540 ;--------------------------- ceiling ------------------------------------------
544 and %111 ;once every 8 frames
545 jr nz,Display_ceiling ;otherwise skip the scroll
546 ld bc,15 ;scroll all 15 bytes (16th is new position)
547 ld hl,ceilingpos+1 ;from..
548 ld de,ceilingpos ;to (one byte to the left)
549 ld a,(de) ;load byte on left (will be lost after scroll)
550 ldir ;LoaDIncreaseRepeat = scroll!
552 ld a,(groundinfo) ;what kind of ceiling
554 jr z,ceiling_tunnel ;tunnel effect
565 jr z,ceiling_previous
571 jr z,ceiling_previous
579 jr z,ceiling_previous
584 ld a,(ceilingpos+14) ;type 1
587 ld a,(ceilingpos) ;type 0
589 ld (ceilingpos+15),a ;save the new byte
592 jr nc,Display_ceiling
599 ld b,16 ;screen width
600 ld de,ceilingpos-1 ;height of current byte
602 ld hl,GRAPH_MEM-17 ;screen position
606 ld c,b ;push b for groundloopup
607 pop hl \ inc hl ;get screen position and go one right
608 pop de \ inc de ;get height info and set to the next byte
609 psh de \ psh hl ;save these for the next time
610 ld a,(de) ;height of current byte
613 ld de,16 ;to substract to go one line up
614 ld a,%11111111 ;bitmask black
617 ld (hl),a ;display black byte
619 dnz ceilingloopdown ;and loop >groundpos< times
621 ld b,c ;pop b used by groundloopup
622 dnz ceilingloopright ;loop right for entire screen (16x)
623 pop hl \ pop hl ;restore stack
626 CheckCeiling: ;check for collision with the ground
630 srl a ;x/8 (current ceiling-byte)
635 ld de,ceilingpos ;first ceiling-byte
636 add hl,de ;current ceiling-byte
639 cp (hl) ;compare with ceiling
640 ret nc ;carry if ceiling is above you
642 jp damage_you ;otherwise you don't wanna be in that ship
644 ;--------------------------- move stars ---------------------------------------
646 DisplayStars: ;inputs: hl=starx# a=stars# b=nrstars#
653 ret ;let's comment this: returns
682 cp 9 ;(GRAPH_MEM&%00001111)-- = $C9FAand15-1 = $A-1
691 ret ;for stupid people, here's another comment...
693 ;--------------------------- pause --------------------------------------------
696 ld hl,$0200 ;top left
698 ld hl,txt_pressenter ;"Enter to continue"
699 cal _puts ;display message
701 cal _getkey ;enter low-power mode and wait for key
702 cp kEnter ;keypressed = enter?
703 jr nz,pause ;no, wait some more
706 ;--------------------------- teacher ------------------------------------------
709 ld (iy+12),5 ;enable flashing cursor
711 cal _homeup ;top left
713 cal _puts ;display message
716 cal _getkey ;enter low-power mode and wait for key
717 cp kEnter ;enter pressed?
719 cp kGrMenu ;keypressed = graph?
720 jr nz,teacherloop ;no, wait some more
722 ld (iy+12),0 ;disable cursor
736 ;--------------------------- exit ---------------------------------------------
740 ld a,(CONTRAST) ;load original contrast level
741 out (2),a ;and set it back
742 ld (iy+13),3 ;use textshadow (TEXT_MEM) and scrolling
744 ld hl,GRAPH_MEM ;graph-screen location
747 ld bc,1024-1 ;do it 1024 times = entire screen
750 jp _clrWindow ;as _clrLCD but also clears TEXT_MEM (like the
751 ;_clrScrn) AND also executes _homeup and ret
754 ;--------------------------- display ------------------------------------------
757 ld hl,GRAPH_MEM ;from storage (top left)
758 ld de,VIDEO_MEM ;to screen (top left)
759 ld c,56 ;display height = 64 bytes (minus 8 for bar)
761 ld b,16 ;display width = 16 bytes (16*8bits=256pixels)
763 ld a,(hl) ;copy byte from (hl)
765 xor $ff ; } ;invert byte (white<=>black)
767 inc hl \ inc de ;next byte
768 dnz displaytloop ;16x hl >> de
770 jr nz,displayloop ;loop 64x
772 ld hl,$396b ;Display Score
773 ld (_penCol),hl ;bottom right of screen
776 _D_HL_DECI: ;------- display 5-digit value -------
777 ld de,savestr+4 ;savenr saves number string
779 ldhld: cal UNPACK_HL ;one digit of hl
780 add a,'0' ;make number
781 ld (de),a ;save into savenr
782 dec de ;point to next digit
783 dnz ldhld ;repeat for all digits
785 ld hl,savestr ;we (the program) saved the value righthere
786 jp _vputs ;the only thing left to do is to display it
788 savestr: ;@here the score will be stored
789 .db "00000",0 ;don't worry, it's just temporary
791 ;------------------------- handle ship ----------------------------------------
798 inc a ;no! next (explosion)frame
799 ld (your_occ),a ;save
801 cp 34 ;last explosion frame?
802 jp c,exploding_you ;not yet: display explosion
803 cp 40 ;delay finished?
804 jp z,You_die ;yes = game over
805 ret ;don't display anything
808 ld a,%01111110 ;get arrow keys
809 out (1),a ;it's cold outside
810 ld hl,y ;instead of nop\nop do something usefull
811 in a,(1) ;come back in
814 xor %11111111 ;inverted a = 0 if arrow-key has been pressed
815 ld a,(your_multiples)
816 jr z,no_adv ;if so, leave the multiples where they are
817 or %100 ;set move bit
819 no_adv: and %11111011 ;reset move bit
821 adv_ok: ld (your_multiples),a
823 ld a,(timer) ;framecounter
824 and %1 ;switches 0<>1 each frame
825 inc a ;a = 1 or 2 (1.5 avg)
826 ld c,a ;c = your_speed
829 rra ;rotate right (put last bit in c)
830 ld b,a ;we need a later
835 cp 50 ;56-6 = bottom of screen
840 rr b ;because we now use b, it's rr instead of rra
843 sub c ;<dec a> doesn't affect c-flag
844 jr c,no_left ;-1 = left side
851 cp 122 ;128-6 = right side
860 sub c ;<dec a> doesn't affect carry-flag
861 jr c,no_up ;-1 = top of screen
862 ld (hl),a ;save new y
865 ld ix,spr_ship01 ;ship sprite
866 ld hl,your_inv ;invulnerable?
867 ld a,(hl) ;load time in a
869 jr z,handle_multiples ;yes so ship = normal (display \ continue)
871 ld a,(timer) ;load frame nr.
872 and %00000111 ;a=0 once every four frames
873 jr nz,not_time ;a<>0 = not time to update counter
874 dec (hl) ;decrease inv-time left
876 and %00000100 ;a switches 0<->1 every 2 frames
877 jr z,handle_multiples ;show normal ship
879 ld ix,spr_ship01i ;don't display ship
882 cal putsprite ;display your ship
884 ld a,(your_multiples) ;do you have multiples
885 ld b,a ;save a for 2nd check
886 and %11 ;no? (last two bits = nr of multiples)
887 ret z ;then don't handle them either
890 ld a,b ;restore a (your_multiples)
891 and %100 ;move the multiples???
892 jr z,mult_adv ;nope, just let them (saves (y) in y, (x) in x)
894 ld hl,your_locpos ;location to save this position
897 and %00001111 ;if a>15 then a=a-16
898 ld (hl),a ;save new a
903 ld hl,your_prevpos ;previous positions
904 add hl,bc ;16 turns ago
908 ld (mx),de ;save multiple position in (mx)
910 ld a,(y) ;load new y-pos
911 ld (hl),a ;save it for 16 turns in the future
913 ld a,(x) ;load new x-pos
914 ld (hl),a ;save that too
918 ld ix,spr_multiple ;sprite of the multiple
919 jp putsprite ;display it + <ret>
922 srl a ;half the framerate
923 dec a ;first frame is 1>inc>srl>dec = 0
941 damage_you: ;damages you B points
942 ld a,(your_inv) ;invulnerability left?
944 ret nz ;return if inv>0
945 ld hl,your_armor ;armor left
946 ld a,(hl) ;load hp in A
947 sub b ;decrease hp by B
948 jp m,no_armor ;<0hp left so explode
949 ld (hl),a ;no, so save decreased hp
950 cal disp_armor ;and display new value
952 ld a,(your_pickup) ;how many pickups do you have?
953 dec a ;is the armor-icon selected
954 ret nz ;return if not
956 psh de \ psh ix ;&&& just2Bsave
957 ld hl,VIDEO_MEM+(16*56)
959 ld ix,spr_icon ;if so, highlight armorIcon again
960 ld de,$1901 ;position
961 cal putwidesprite ;display icon
968 ld a,%01 ;occ %xxxxxx01 = explode
969 ld (your_occ),a ;set to explode
972 ;------------------------- place multiples ------------------------------------
975 ld (mx),de ;set last multiple-position
976 ld hl,your_prevpos ;place all previous positions
977 ld b,16 ;all 16 of them
979 ld (hl),d ;set prev-x to d
981 ld (hl),e ;set prev-y to e
983 dnz place_multiples ;repeat
986 ;------------------------- select upgrade -------------------------------------
989 ld hl,your_pickup ;select pickups
990 ld a,(hl) ;load pickups taken so far
992 ret m ;return if it's 0 (no pickups)
993 jr nz,select2 ;no, carry on
995 ld a,(your_armor) ;load current armor
997 ret nc ;then return (armor may not be 25 or more)
999 ld (your_pickup),a ;reset pickups (a=0)
1000 ld hl,your_armor ;change armor
1001 inc (hl) ;increase HPs by one
1002 jp disp_icons ;display and return
1005 jr nz,select3 ;no, carry on
1006 ld (hl),a ;reset pickups
1008 ld (torp_occ),a ;ready torpedoes
1009 jp disp_icons ;display 'n return
1012 jr nz,select4 ;no, carry on
1013 ld (hl),a ;reset pickups
1018 jp nc,disp_icons ;>=10
1026 ld hl,XLweapondata-7
1031 jp disp_icons ;display n return
1034 jr nz,select5 ;no, carry on again
1035 ld (hl),a ;reset pickups
1037 ld (your_weapon),a ;ready laser
1038 jp disp_icons ;display + return
1041 jr nz,select6 ;no, carry on once more
1042 ld (hl),a ;reset pickups
1044 ld (your_multiples),a
1047 jp disp_icons ;display, return
1049 ld (hl),0 ;reset pickups
1050 jp disp_icons ;display/return
1052 ;------------------------- fire bullet ----------------------------------------
1055 ld hl,RanPos ;random
1056 inc (hl) ;update random counter
1061 ld a,(hl) ;just_fired
1062 cp 5 ;already pressed?
1063 ret z ;return when already pressed (=5)
1065 inc (hl) ;otherwise increase counter (0 to 4 >> 1 to 5)
1066 ld a,(your_weapon) ;if you have bullets.....
1069 ld (hl),5 ;.....then can't fire next turn (go to 5 imm.)
1072 ld hl,(x) ;yes: first fire from ship position (x)
1073 ld (firex),hl ;set firepos
1074 ld a,(your_multiples) ;any multiples?
1076 jr z,fireany ;then just fire somethin'
1077 cal fireany ;and blast
1078 ld hl,(my) ;then, fire from multiple position (mx)
1081 ld (firex),hl ;set firepos
1082 ;blast again and <ret>
1086 ld a,(your_weapon) ;do you have laser?
1090 ld ix,XLweapondata-6
1116 ld hl,torp_occ ;torpedo...
1117 ld a,(hl) ;load torpInfo
1118 dec a ;do you have (unused) torpedoes?
1119 ret nz ;nope (a must be 1)
1120 ld (hl),2 ;yes; use torpedo
1121 ld (torp_pos),de ;save torpedo position (in de)
1125 fire_laser: ;yes, fire that laser instead
1126 ld a,(firex) ;a = your x-pos
1129 ld hl,GRAPH_MEM ;save-location
1130 ld a,(firey) ;y-coord
1131 add a,3 ;at middle of your ship (y+3)
1132 ld e,a ;save laser-y in e
1136 rl b ;b (=0) =b*2+overflow (if y>32 then bc=bc+256)
1137 add a,a ;y*16 (width of screen)
1138 rl b ;b=b*2+overflow (if y>64 then bc=bc+512)
1139 inc a ;8 pixels to right (a=even so no overflow)
1144 add a,d ;a = (Y*16+X/8) mod 256 (c set on overflow)
1145 jr nc,_nolc ;jump if no carry = no overflow = a<=255
1146 inc b ;a>255 so increase bc by 256
1147 _nolc: ld c,a ;c = (Y*16+X/8) mod 256
1148 add hl,bc ;bc = Y*16+X/8
1150 ld a,15 ;128/8=16=screen width ** minus one (inc a ^^)
1151 sub d ;minus x-start (d=X/8)
1155 inc hl ;Go to next byte
1158 ; ld a,(just_fired) ;fired for how long
1160 ; ret nz ;then do damage, otherwise quit
1164 ld d,a ;d was divided, so reload the laser-x
1166 check_laserhits: ;de = (x,y)
1170 laserhits: ;Hits with normal enemies
1175 jr z,nolashit ;no hit when enemy_occ <> 2/3
1179 or a ;enemy #0 = pickup
1180 jr z,nolashit ;yes: don't destroy
1185 jp m,nolashit ;no hit when enemy is left of you
1190 jr z,enemy_lashit ;a-e=0 = laser on top line of enemy = hit
1191 jr nc,nolashit ;a-e>0 = enemy above laser = no hit
1192 add a,5 ;add enemy height
1193 jp p,enemy_lashit ;a-e>0 = hit
1199 add hl,bc ;go to next enemy
1201 dnz laserhits ;check all enemies
1216 jr z,found_ybullet ;0 = no bullet here
1218 dnz find_ybullet ;look next bullet
1222 ld (hl),c ;use the bullet and set correct bullet-type
1223 ld a,(firex) ;your x-pos
1224 add a,5 ;place bullet in front of you
1225 inc hl ;go to bullet-x
1228 ld a,(firey) ;your y-pos
1229 add a,(ix+1) ;place bullet at the middle of your ship
1230 inc hl ;go to bullet-y
1234 ;------------------------ handle bullets --------------------------------------
1240 cp (hl) ;off screen? (x>128-5)
1243 add a,b ;move b to the right
1244 ld (hl),a ;save new pos.
1284 ld (hl),0 ;dump this bullet!
1295 ld (temp1),hl ;needed for check_bullethits
1300 jp z,next_ybullet ;bulletType=0 >> no bullet
1305 cal bullet_left ;move bullet left
1310 cal putsprite ;display bullet
1313 cal check_bullethits
1321 dnz scan_bullets ;next bullet (loop)
1324 ;--------------------------- check bullethits --------------------------------
1326 check_bullethits: ;INPUT: de=X,Y; (temp1)=bullet
1330 hit_enemies: ;Hits with normal enemies
1335 jr z,nohit ;no hit when enemy_occ <> 2/3
1339 or a ;enemy #0 = pickup
1340 jr z,nohit ;yes: don't destroy
1366 ld (hl),$00 ;remove bullet
1377 dnz hit_enemies ;check next enemy
1386 and %11111100 ;occ/4 = HP left ;<srl a\srl a
1387 jr nz,hpleft ;not zero -> jump
1388 ld (hl),%01 ;set to explode
1390 ld a,(pickuptimer) ;counts enemies destroyed
1391 dec a ;enough destroyed for a pickup?
1392 jr nz,pickupdone ;otherwise just explode
1393 ld (hl),%00000110 ;change it into a pickup (with 2 HP)
1394 ld a,18 ;reset enemies counter (18 hits = next)
1396 ld (pickuptimer),a ;save new enemiescounter value
1398 ld (hl),$00 ;explosionFrame 0
1400 ld hl,1 ;increase score by one
1405 sub %00000100 ;decrease HP by one
1409 ;--------------------------- handle torpedo ----------------------------------
1414 ret m ;return if occ=0/1
1416 ld hl,torp_pos ;x-position
1417 ld a,(hl) ;load in a
1419 cp 125 ;right edge reached
1420 jr nc,remove_torp ;remove if x>125
1421 ld (hl),a ;save new x
1427 cp 56 ;bottom reached
1428 jr nc,remove_torp ;remove if y>40
1429 ld (hl),a ;save new y
1434 cal putsprite ;display torpedo
1436 jp check_bullethits ;check for hits with enemies
1443 ;--------------------------- level events -------------------------------------
1446 ld hl,nextevent ;time to next event <ld a,(nextevent)
1447 dec (hl) ;decrease counter <dec a
1448 ld a,(hl) ;look at counter <ld (nextevent),a
1449 or a ;has it reached zero?
1450 ret nz ;nope: get outta here!
1452 ld a,(eventtime) ;enemy frequency (lvl)
1453 ld (nextevent),a ;set time to next event
1455 dec (hl) ;update enemy-counter
1457 ld a,(hl) ;look at counter
1458 or a ;has it reached 0?
1459 jp z,Next_level ;yes: level finished
1460 dec a ;has it reached 1?
1461 jr z,standby_event ;yes: wait until no enemies present/left
1462 dec a ;has it reached 2?
1463 jr z,place_boss ;yep: place the BigBossTM!
1464 dec a ;has it reached 3?
1465 jr nz,do_event ;nope: >3 = place an enemy
1466 inc hl ;nextevent located behind eventleft
1467 ld (hl),123 ;set delay
1468 ret ;don't place any more enemies
1471 ld hl,(levelp) ;the leveldata (including the boss)
1472 dec hl ;points to leveldata\boss\enemynr
1474 ld (level_enemy),a ;set new enemy (boss)
1475 dec hl ;points to level\boss\movement
1477 ld (level_move),a ;set boss movement
1478 dec hl ;@level\boss\firefreq
1479 ld a,(hl) ;load in a
1480 ld (level_fire),a ;set firefrequency
1485 ld hl,enemies-enemysize
1490 or a ;0 = no enemy present
1501 ld hl,enemies-enemysize
1506 cp (hl) ;(hl) = 0 ??
1507 jr nz,chk_noenemy ;jump if enemy present (non-0)
1513 ld a,(level_enemy) ;enemy type to place (lvl)
1514 ld hl,XLenemyinfos-4 ;enemy "0" specs (1 before enemy #1)
1518 ld b,0 ;bc = enemy nr.&&&XX
1519 add hl,bc ;hl = enemy specs
1520 ld a,(hl) ;load hitpoints+occ of this enemy class
1523 inc hl ;next enemyInfo byte
1524 inc de ;next byte of current enemy
1525 ld a,(hl) ;load enemy class (nr)
1526 ld (de),a ;save enemy type
1532 ld a,128 ;appear at right edge of screen
1533 sub (ix) ;minus the width of this enemy (not offscreen)
1534 ld (de),a ;= x-position (save)
1537 inc hl ;where to place??
1538 ld a,(hl) ;load placeInfo
1540 jr z,random_enemy ;yes: create random value <51 in a
1542 jr z,lure_enemy ;yes: create a 100% luring enemy
1544 halflure_enemy: ;yes (of course it is): pick one (50% lure)
1545 ld a,(timer) ;look at frame-number
1546 and %00000001 ;make random if odd frame nr.
1547 jr nz,random_enemy ;1st possibility: random enemy
1548 lure_enemy: ;2nd possibility: luring enemy
1549 ld a,(y) ;place at same y-pos as YOUR ship
1553 ld b,e ;b will be added to random-value
1554 cal Random50 ;make a (in a) random value 0-51
1556 ypos_OK: ;random value successfully created
1557 ld (de),a ;save y-position
1560 ld a,1 ;movecounter = 1
1561 ld (de),a ;&&&(hl),1 better?
1565 and %00000001 ;bit meaning directfire
1566 jr nz,ffireOK ;(a=time-to-fire) = 1 frame (fires directly)
1567 ld a,(level_fire) ;set ttf to normal nr of frames
1568 ffireOK:ld (de),a ;save fire
1571 ;--------------------------- enemy fires --------------------------------------
1573 Enemy_fires: ;de = x,y
1583 jr z,found_ebullet ;0 = not used
1584 inc hl \ inc hl \ inc hl
1585 dnz find_ebullet ;look next bullet
1598 ld b,%1011 ;yourY-bulY = negative (=bullet below you)
1601 ld b,%1001 ;yourY-bulY = even more negative (going up)
1606 ld b,%1010 ;bullet going down
1608 jp m,bulletok ;even more going down
1615 ld (hl),a ;set bullet direction
1617 ld (hl),d ;set x-pos
1619 ld (hl),e ;set y-pos
1622 ;----------------------------- enemy bullets ----------------------------------
1630 ld a,(hl) ;load bulletType in a
1631 and %1111 ;select direction-bits
1632 jr nz,enemy_bullet ;non-0: handle bullet
1634 pop hl ;do not move the <pop hl>
1636 inc hl \ inc hl \ inc hl
1641 ld b,a ;save type&%1111
1643 ld a,(hl) ;check if it has reached the left side of scrn
1644 and %11111110 ;it is <2 (0 or 1)?
1645 jr z,remove_ebullet ;yes, remove bullet
1646 dec (hl) ;move one left
1647 dec (hl) ;and another one
1651 ld a,b ;restore type
1652 cp %1100 ;is it a normal bullet? (cp = faster than bit)
1653 jr z,ebullet_common ;type %1100: normal bullet
1654 and %111 ;isolate important bits
1655 jr z,ebullet_down ;type %1000: moving down
1657 jr z,ebullet_up ;type %1001: moving up
1666 jr z,ebullet_down ;type %1010: moving down 50%
1667 ;type %1011: moving up 50%
1684 ld ix,spr_bullete1 ;display enemy bullet
1690 jr nz,next_bullet ;0 = you're normal
1710 pop hl ;points to bullettype again
1711 psh hl ;and save it again (ivm call to damage_you)
1712 ld a,(hl) ;load bullettype
1713 cal _shracc ;isolate damage-bits (%1111???? -> %00001111)
1714 ld b,a ;set damage-amount
1715 cal damage_you ;HIT!!
1717 pop hl ;hl could be destroyed by damage_you
1718 ld (hl),0 ;bullet > unused
1719 jr next_bullet+1 ;next bullet (SKIP THE <POP HL> = one byte)
1721 ;--------------------------- handle enemies -----------------------------------
1725 ld b,nrenemies ;handle all enemies
1733 jr z,next_enemy ;occ "no enemy" 0
1735 jr z,exploding_enemy ;occ "exploding" 1
1736 ld b,a ;b=2 if moving, otherwise b=1
1738 normal_enemy: ;occ "normal" 2 or "moving" 3
1740 ld c,(hl) ;c = enemy type = de
1746 jr c,remove_enemy ;off screen
1747 jr z,remove_enemy ;"
1752 ld a,b ;moving state was stored in b earlier
1754 cal nz,moving_enemy ;2 = moving enemy
1758 ld (hl),d ;store new x
1759 ld a,c ;a = enemy type
1760 or a ;type 0? (pickup)
1761 jr nz,check_enemyfire ;no, a normal enemy; let em fire
1762 ld a,(timer) ;load time
1763 and %1 ;move left once every 2 turns
1764 jr z,firing_done ;don't move now
1765 inc d ;increase x-position (don't move this turn)
1766 inc (hl) ;and save it
1767 jr firing_done ;continue
1771 inc hl ;go to <move>
1772 inc hl ;go to <fire>
1773 dec (hl) ;decrease counter till next blast
1774 ld a,(hl) ;&&&doesn't seem efficient to me
1775 or a ;has it reached zero?
1776 jr nz,firing_done ;finished if not
1778 ld a,(level_fire) ;re-set counter for next blast
1779 ld (hl),a ;save time to fire
1780 inc hl ;next byte = bullettype &&&
1781 psh de ;save registers for firing-use
1782 cal Enemy_fires ;fires bullet
1783 pop de ;restore (destroyed by Enemy_fires)
1785 cal putwidesprite ;display sprite @ix
1797 ld (hl),$0000 ;bye bye enemy
1798 jr next_enemy+1 ;continue AFTER pop hl (already done)
1804 cal explosion_stuff ;display explosion
1809 jr z,remove_enemy ;remove when at last frame
1811 ld (hl),a ;next frame
1814 ;--------------------------- moving enemies -----------------------------------
1819 jr z,movetype_updown ;type 0
1821 jr z,movetype_vslow ;1
1823 jr z,movetype_fast ;2
1825 jr z,movetype_vfast ;3
1827 jr z,movetype_smart ;4
1829 jr z,movetype_lure ;5
1831 jr z,movetype_slowlure ;6
1833 jr z,movetype_stoplure ;7
1835 ; jr z,movetype_fulllure ;8
1855 jr movetype_slowlure
1874 inc hl ;hl =@ <move>
1883 or a ;reset carry flag
1884 dec hl ;reset hl to <y>
1902 pop hl ;restore stack (no ret used)
1903 jp remove_enemy ;remove this enemy (off screen)
1914 or a ;reset carry flag
1917 ld a,(hl);&&&ld a,e ;load current y-position
1920 moveup: dec a ;decrease y-pos (=move up)
1921 ret m ;don't move off the screen (y<0)
1922 dec e ;save new y-pos
1925 inc a ;increase y-pos
1926 cp 55 ;compare with bottom
1927 ret nc ;return if it has passed that line (>40)
1928 inc e ;otherwise save new position
1931 ;--------------------------- check collision ----------------------------------
1934 ld hl,(x) ;e = X, d = Y
1935 ld de,$0707 ;add 7 to both d and e
1938 ld e,l ;e = X+7, d = Y+7
1941 ld b,nrenemies ;check all 20 enemies
1946 jr z,check_next ;2 or 3 = ok
1949 collide_enemy: ;&&& include in Handle_enemy proc
1955 ld a,(hl) ;check x match
1956 sub e ;enemy position minus yours minus 7
1963 ld a,(hl) ;check y match
1964 sub d ;same as with x-check
1974 ld hl,2 ;increase score by 2
1978 ld a,(hl) ;load enemy type
1980 jr nz,collide ;enemy when <>0
1983 ld hl,your_pickup ;your pickups
1988 ld a,1 ;yes: reset to pickup 1
1991 cal disp_icons ;display altered pickupicons
1994 dec hl ;to enemy occ
1995 xor a ;set to 0 = gone
1997 jr check_next ;all done, next..
2000 ld (hl),%01 ;set to explode
2002 ld (hl),0 ;explosionFrame 0
2026 ;--------------------------- story -------------------------------------------
2064 cal storyPage ;do some story
2065 inc hl ;look at next hl
2066 ld a,(hl) ;load in a
2068 inc a ;set z-flag if a = $ff
2069 jr nz,dostory ;otherwise loop
2072 add hl,bc ;set hl to beginning of the level
2073 ld (levelp),hl ;set the level-pointer
2076 ;--------------------------- SFX ---------------------------------------------
2086 DoSFX: ;ins: a=beginLine b=nrOfLines
2091 ld a,(curline) ;get line number
2092 inc a ;go to the next line
2093 ld (curline),a ;update
2102 ld b,h ;save hl for later
2106 add hl,de ;go to ymin
2113 ld a,(curline) ;Calculate how many lines to draw
2119 SFXdisp: ;display this frame on screen
2120 ld a,b ;psh b (a will not be used)
2121 ld bc,16 ;one line (=16 bytes, you'd know by now)
2122 ldir ;display (copy actually)
2123 ld bc,-16 ;go up one line (not on screen)
2124 add hl,bc ;so the same line will be displayed
2126 dnz SFXdisp ;repeat until whole screen is displayed
2137 ;--------------------------- show icon ----------------------------------------
2140 ld (hl),a ;draw one piece of the divider-line
2141 inc hl ;move right (8 pixels = 1 byte)
2142 dnz drawline ;repeat (16bytes * 8pixels =128= screen width)
2146 psh bc \ psh de \ psh hl \ psh ix ;&&&
2148 ld hl,VIDEO_MEM+(16*56);56 rows down = eight rows from bottom
2149 ld (PutWhere),hl ;place icons at bottom of normal screen
2150 ld b,16 ;draw 16x (screen width)
2151 ld a,%11111111 ;horizontal line mask
2152 cal drawline ;draw divider-line
2154 ld b,16*7 ;draw 16x (screen width) 7x (height)
2155 xor a ;blank line mask
2156 cal drawline ;clear scorebar
2160 ld ix,spr_icon01 ;armorIcon
2161 ld de,$1901 ;icon #1
2162 cal putwidesprite ;display icon
2163 cal disp_armor ;display bar
2169 ld ix,spr_icon02 ;torpedoIcon
2171 ld de,$2901 ;icon #2
2172 cal putwidesprite ;display
2174 ld ix,spr_icon03 ;bulletIcon
2175 ld de,$3901 ;icon #3
2176 cal putwidesprite ;display icon
2177 ld hl,$3945 ;position to display bullet-type digit
2178 ld a,(your_weapon) ;digit
2179 dec a ;minus one (1=laser)
2180 ld (_penCol),hl ;set location
2181 add a,'0' ;make digit
2182 cal _vputmap ;display char
2184 ld ix,spr_icon00 ;emptyIcon
2188 ld ix,spr_icon04 ;laserIcon
2190 ld de,$4901 ;icon #4
2193 ld ix,spr_icon00 ;emptyIcon
2194 ld a,(your_multiples)
2199 ld de,$5901 ;icon #5
2202 ld ix,spr_dividerline
2206 ld a,(your_pickup) ;pickups taken
2207 add a,a ;picks*2 (sets z-flag)
2208 jr z,iconsdone ;return if no pickups
2213 ld d,a ;y-pos = picks * $10 + $0a (19,29,39,49,59)
2214 ld e,$01 ;x-pos = bottom (1a01,2a01,3a01,4a01,5a01)
2219 ld hl,GRAPH_MEM ;normal game-screen
2220 ld (PutWhere),hl ;set sprite-position to normal screen
2222 pop ix \ pop hl \ pop de \ pop bc
2226 ld hl,(57*16)+VIDEO_MEM+3
2233 ld a,(your_armor) ;load your armor
2237 srl a ;/8: don't display last 2 bits of a (later)
2238 jr z,noarmorbar ;if a=0 then it would loop 256x so skip it
2239 ld b,a ;loop b=a times
2240 armorbar: ;starting at ($39*16)+VIDEO_MEM
2241 ld (hl),%11111111 ;draw a piece of the bar
2242 inc hl ;next position
2243 dnz armorbar ;loop it b times
2247 and %111 ;display last bits of armor
2248 ret z ;if armor=0 then bit = %00000000 (don't disp)
2250 xor a ;bit = %00000000
2253 rra ;rotates A right and sets bit 7 (c-flag)
2254 dnz armorbarbit ;repeat B times (so if B=6 then a=%11111100)
2255 armorbarready: ; (an if B=3 then a=%11100000)
2256 ld (hl),a ;draw this last byte
2260 ld hl,$3A00 ;display Lives
2261 ld (_penCol),hl ;bottom left
2268 ld a,(your_lives) ;nr of lives in a
2269 add a,'0' ;make digit
2272 jp _vputs ;display on screen +ret
2274 ;--------------------------- proc ---------------------------------------------
2277 cal Random50 ; a = 0..50
2281 add hl,hl ;hl = 1..51 * 2
2282 add hl,hl ;hl = 1..51 * 4
2283 add hl,hl ;hl = 1..51 * 8
2284 add hl,hl ;hl = 1..51 * 16 (left side at random y)
2285 dec hl ;hl = 1..51 * 16 (" at right side of screen)
2287 add hl,de ;position on screen
2292 cp 51 ;y may not be more than 50
2294 and %00111111 ;a = 0..63
2297 add a,13+(50-12) ;a = -13..-1 >=> 0..12 >=> 39..50
2301 ld a,(RanPos) ;a handy random-var.
2302 ld hl,x ;add your x-coord for randomness
2304 inc hl ;add your y-coord for randomness
2306 ld (RanPos),a ;save altered random-var
2307 ret ;RanPos also in #a
2317 find_sprite: ;destroyed: de ix
2319 ld e,(hl) ;e = enemy type
2321 ld hl,XLenemytable ;hl = @sprites offset-table
2322 add hl,de ;points to offset of current enemy offset
2323 ld e,(hl) ;de = @enemy offset
2326 ld ix,XLsprenemies ;first enemy sprite
2327 add ix,de ;add offset for current enemy
2328 add ix,de ;twice (offset stored as offset/2)
2333 ld hl,VIDEO_MEM ;screen location (top left)
2336 ld bc,1024-1 ;do it 1024 times = entire screen
2338 set 3,(iy+5) ;set white on black
2345 jr nz,waitnokeypressed
2348 Decompress: ;hl=source(compressed) de=dest(decompressed)
2383 ;--------------------------- game over / new game / death ---------------------
2385 .db 0,"!<>^",0,0,0,0
2386 .db 0,"xtoje0",0 ;enter..clear
2387 .db " wsnid9",0 ;(-)..custom
2388 .db "zvrmhc8",0 ;dot..del
2389 .db "yuqlgb7x" ;0..xvar
2390 .db 0,"-pkfa6'" ;on..alpha
2391 .db "54321.",0,0 ;F5..more
2397 ld hl,own_name-1 ;find own variable
2398 rst 20h ;cal _ABS_MOV10TOOP1
2399 rst 10h ;cal _FINDSYM
2400 ret c ;not found? who cares...
2403 ld hl,4+storehi_start-_asm_exec_ram
2404 add hl,de ;hl=pointer to data in original prog
2406 cal _SET_ABS_DEST_ADDR
2409 cal _SET_ABS_SRC_ADDR
2410 ld hl,storehi_end-storehi_start
2411 cal _SET_MM_NUM_BYTES
2412 jp _mm_ldir ;save done (cal \ ret)
2415 ld hl,own_name-1 ;find own variable
2416 rst 20h ;cal _ABS_MOV10TOOP1
2417 rst 10h ;cal _FINDSYM
2418 ret c ;not found? who cares...
2421 ld hl,4+storesave_start-_asm_exec_ram
2422 add hl,de ;hl=pointer to data in original prog
2424 cal _SET_ABS_DEST_ADDR
2426 ld hl,storesave_start
2427 cal _SET_ABS_SRC_ADDR
2428 ld hl,storesave_end-storesave_start
2429 cal _SET_MM_NUM_BYTES
2430 jp _mm_ldir ;save done (cal \ ret)
2434 pop hl ;=ret (game_over was called from a procedure)
2436 cal BLACKLCD ;clear screen
2437 cal waitnokeypressed
2439 ld (_curRow),hl ;center
2441 cal _puts ;display "GAME OVER"
2491 cal waitnokeypressed
2522 xor a ;clear a (Ahl will be displayed)
2523 ld hl,$1006 ;bottom-1 right
2524 ld (_curRow),hl ;set
2525 ld hl,(score) ;your score
2526 cal _dispahl ;display it (a=0)
2528 ld hl,$314b ;bottom-1 right before score ^^
2529 ld (_penCol),hl ;set
2530 ld hl,txt_score ;"Score"
2531 cal _vputs ;display (small)
2533 ld hl,$1007 ;bottom right
2534 ld (_curRow),hl ;set
2535 ld hl,(hiscore) ;hi-score
2536 cal _dispahl ;display
2537 ld hl,$3946 ;bottom right before hiscore ^^
2538 ld (_penCol),hl ;set
2539 ld hl,txt_hiscore ;"Hiscore"
2540 cal _vputs ;display (small)
2545 ld hl,VIDEO_MEM+(49*16)-1
2551 cal _getkey ;wait for keypress
2552 jp quit ;restore some things and return to TI-OS/shell
2559 ld (score),a ;reset score
2560 ld (score+1),a ;reset score (0)
2561 ld (torp_occ),a ;no torpedoes
2562 ld (your_weapon),a ;no laser
2563 ld (your_pickup),a ;reset pickups
2564 ld (your_multiples),a ;no multiples
2566 ld (level),a ;reset level nr (#1)
2567 ld hl,XLlevelsdata ;set level pointer to level#1
2568 ld (levelp),hl ;reset level pointer
2570 ld (your_weapon),a ;default weapon
2572 ld (your_lives),a ;3 lives (4 will be decreased @ You_die)
2573 ld (pickuptimer),a ;next pickup after 4 enemies destroyed
2581 ld (your_armor),a ;5 HPs/shields
2583 dec (hl) ;decrease lives
2584 ld a,(hl) ;load lives left
2585 inc a ;if lives=0ffh then a=0
2586 jp z,game_over ;if so, game's over
2589 ;--------------------------- next level ---------------------------------------
2592 ld hl,level ;level number
2599 ld h,0 ;increase score....
2600 ld l,a ;by level number * 4
2603 cal scoreInc ;update score
2605 ld hl,(levelp) ;level pointer
2606 ld bc,5+32+4+4 ;advance one level
2607 add hl,bc ;update to point to next level
2608 ld (levelp),hl ;save
2621 ld hl,XLweapondata-7
2624 ld (ybuls),a ;max number of bullets (varies per weap.class)
2627 ld (nextevent),a ;time to first enemy appearance
2629 ld hl,(levelp) ;level pointer
2630 ld a,(hl) ;load new level-enemy type
2631 ld (level_enemy),a ;set level-enemy
2633 ld a,(hl) ;load new appearance-time
2634 ld (eventtime),a ;set
2636 ld a,(hl) ;load nr of enemies in this level
2637 ld (eventleft),a ;set nr of events left
2642 ld a,(hl) ;movement of enemies in this level
2643 ld (level_move),a ;do it
2645 ld a,(hl) ;how frequent the enemies fire a bullet
2646 ld (level_fire),a ;consider it done
2663 ld (timer),a ;reset time
2664 ld hl,your_occ ;hl = your_occ
2665 ld (hl),a ;reset your ship (not exploding)
2666 inc hl ;hl = your_inv
2667 ld (hl),25 ;set 25*4=100 frames invulnerable
2668 ld hl,x ;begin position x=...
2669 ld (hl),a ;...=a=0=left
2671 ld a,24 ;...=24=middle
2676 jr z,torpsclear ;then just continue (=0)
2677 ld a,1 ;if so, set to "ready to fire" (=1)
2680 ld de,$0018 ;x=0, y=24 (like you..)
2681 ; cal Place_multiples ;place all multiple-positions at (0,24)
2683 ld hl,enemies ;remove all enemies and bullets
2684 ld (hl),0 ;clear first byte
2685 ld de,enemies+1 ;copy this to the next byte
2686 ld bc,(nrenemies*enemysize)+((nrybuls+nrebuls)*3)-1
2687 ldir ;clear enemies + bullets (y/e)
2689 ;--------------------------- setup game ---------------------------------------
2694 ld (_curRow),hl ;center
2696 cal _puts ;display "LEVEL "
2707 cal _putc ;display second digit
2709 cal _putmap ;display first digit
2712 ld (_curRow),hl ;display lives left below level nr
2713 ld hl,txt_lives ;bar text: "Lx0"...
2714 ld a,(your_lives) ;lives left
2715 add a,'0' ;make value
2716 ld (txt_lives+3),a ;add to text
2717 cal _puts ;display the string
2718 res 3,(iy+5) ;set white on black
2720 cal _getkey ;wait for keypress
2724 cal _clrLCD ;clear screen
2725 jp disp_icons ;display bottom icons +ret
2728 cal Random5016 ;a = (0..50)*16 = random y-pos
2729 ld a,b ;a = b = star nr. = 1..7
2730 add a,a ;a = 2b = 2..14
2732 ld e,a ;de = a = 2-14
2733 add hl,de ;add to random y => random pos anywhere
2735 ld (ix),l ;save x-pos (l)
2736 ld (ix+1),h ;save y-pos (h)
2737 inc ix \ inc ix ;next star
2738 dnz placestars ;repeat for all stars
2741 ;--------------------------- putsprite ----------------------------------------
2742 ;--------------------------- de =(X,Y) ----------------------------------------
2745 .db 128,64,32,%10000,%01000,%00100,%00010,%00001
2748 and %00000111 ;a = X mod 8 = bit nr. to mask
2749 ld hl,offsets_table ;pixel mask table
2752 add hl,bc ;add to table
2753 ld a,(hl) ;a = pixel mask
2754 ld (_smc1+1),a ;alter pixel mask
2756 ld hl,GRAPH_MEM ;save-location
2761 rl b ;b (=0) =b*2+overflow (if y>32 then bc=bc+256)
2762 add a,a ;y*16 (width of screen)
2763 rl b ;b=b*2+overflow (if y>64 then bc=bc+512)
2766 srl d ;d/8 (8 bits in byte) ** c is set when overflow
2767 add a,d ;a = (Y*16+X/8) mod 256
2768 jp nc,_n1 ;jump if no carry = no overflow = a<=255
2769 inc b ;a>255 so increase bc by 256
2770 _n1: ld c,a ;c = (Y*16+X/8) mod 256
2771 add hl,bc ;bc = Y*16+X/8
2775 _oloop: psh bc ;Save # of rows
2776 psh hl ;Save screen address
2778 ld c,(ix+2) ;Load one line of image
2780 _smc1: ld a,1 ;Load pixel mask
2781 _iloop: sla c ;Test leftmost pixel
2782 jp nc,_noplot ;See if a plot is needed
2783 ld e,a ;OR pixel with screen
2788 jp nc,_notedge ;Test if edge of byte reached
2789 inc hl ;Go to next byte
2792 pop hl ;Restore address
2793 ld bc,16 ;Go to next line
2795 pop bc ;Restore data
2797 ret ;<jp>s are used instead of <jr> = faster
2799 ;--------------------------- putbigsprite -------------------------------------
2832 woloop: psh bc ;Save # of rows
2833 psh hl ;Save screen address
2835 ld c,(ix+2) ;Load one line of image
2837 wsmc1: ld a,1 ;Load pixel mask
2838 wiloop: sla c ;Test leftmost pixel
2839 jr nc,wnoplot ;See if a plot is needed
2840 ld e,a ;OR pixel with screen
2846 jr nc,wnotedge ;Test if edge of byte reached
2847 inc hl ;Go to next byte
2853 pop hl ;Restore address
2854 ld bc,16 ;Go to next line
2856 pop bc ;Restore data
2871 ;------------------------------------------------------------------------------
2872 ;------------------------------- sprites --------------------------------------
2873 ;------------------------------------------------------------------------------
2876 .db 7,7 ;ship alpha class
2877 .db %01111000 ; ████
2879 .db %01111100 ; █████
2880 .db %11110010 ; ████ █
2881 .db %01111100 ; █████
2883 .db %01111000 ; ████
2885 .db 7,7 ;ship alpha class
2896 .db %01010100 ; █ █ █
2897 .db %10100010 ; █ █ █
2898 .db %01010100 ; █ █ █
2903 ; .db 7,7 ;ship beta class
2904 ; .db %11100000 ; ███
2905 ; .db %11110000 ; ████
2906 ; .db %01111100 ; █████
2907 ; .db %01110010 ; ███ █
2908 ; .db %01111100 ; █████
2909 ; .db %11110000 ; ████
2910 ; .db %11100000 ; ███
2912 ; .db 7,7 ;ship beta class
2914 ; .db %10100000 ; █ █
2915 ; .db %01010100 ; █ █ █
2916 ; .db %00100010 ; █ █
2917 ; .db %01010100 ; █ █ █
2918 ; .db %10100000 ; █ █
2923 .db %01111000 ; ████
2924 .db %11111100 ; ██████
2925 .db %11111100 ; ██████
2926 .db %01111000 ; ████
2929 .db 5,3 ;your bullets
2930 .db %00110000 ; ░▒▓█▒
2931 .db %11111000 ; ░▒▓████▒
2932 .db %00110000 ; ░▒▓█▒
2935 .db %11110000 ; ░▒▓███▒
2936 .db %11111000 ; ░▒▓████▒
2937 .db %11110000 ; ░▒▓███▒
2941 .db %11110000 ; ████
2945 .db 4,3 ;enemy bullets
2946 .db %01100000 ; ▒█▓▒░
2947 .db %11110000 ; ▒███▓▒░
2948 .db %01100000 ; ▒█▓▒░
2950 ;---------------------------------------- explosion -------------------------------------------
2956 .db %00111110 ; █████
2957 .db %01010110 ; █ █ ██
2963 .db %01001110 ; █ ▒███
2964 .db %10111110 ; █ █████
2965 .db %01001111 ; █ ▒████
2967 .db %00011010 ; ██ █
2970 .db %10110000 ; █ ██
2971 .db %01001110 ; █ ███
2972 .db %10110101 ; █ ██▒█▒█
2973 .db %01000101 ; █ ▒█▒█
2974 .db %00111110 ; █████
2975 .db %01011010 ; █ ██ █
2978 .db %00101010 ; ▒ █▒█ █
2979 .db %01000110 ; █ ▒██
2980 .db %10110101 ; █ ██ █ █
2981 .db %01100110 ; ██ ██▒
2982 .db %00111100 ; ████▒
2983 .db %01011001 ; █ ██ ▒█
2986 .db %01000000 ; █▒ ▒ ▒
2987 .db %00100101 ; ▒█ █▒█
2988 .db %00010100 ; ▒ ▒█ █ ▒
2989 .db %01000100 ; █▒ █
2990 .db %00010010 ; ▒█▒▒█
2991 .db %10011010 ; █▒ ██ █▒
2995 .db %00100000 ; ▒█ ▒ ▒
2996 .db %00000001 ; ▒ ▒ █
2998 .db %00100010 ; █▒ █
2999 .db %01001000 ; ▒█ ▒█ ▒
3002 .db %00001000 ; ▒ █▒
3003 .db %11000010 ; ██ ▒ █
3005 .db %00100000 ; ▒█ ▒
3006 .db %00000001 ; ▒ ▒█
3007 .db %00110000 ; ▒██▒
3011 .db %00000000 ; ▒▒ ▒
3015 .db %00100100 ; █▒ █
3026 ;--------------------------------------- bar -----------------------------------
3029 .db 16,7 ;selected .......:
3030 .db %11111111 ; ████████
3036 .db %11111111 ; ████████
3038 .db 16,7 ;selected .......:.......:
3039 .db %11111111,%11111111 ; ████████████████
3040 .db %11000000,%00000001 ; ██ █
3041 .db %11000000,%00000001 ; ██ █
3042 .db %11000000,%00000001 ; ██ █
3043 .db %11000000,%00000001 ; ██ █
3044 .db %11000000,%00000001 ; ██ █
3045 .db %11111111,%11111111 ; ████████████████
3047 .db 16,7 ;unused .......:.......:
3048 .db %10101010,%10101010 ; █ █ █ █ █ █ █ █
3049 .db %11010101,%01010101 ; ██ █ █ █ █ █ █ █
3050 .db %10101010,%10101010 ; █ █ █ █ █ █ █ █
3051 .db %11010101,%01010101 ; ██ █ █ █ █ █ █ █
3052 .db %10101010,%10101010 ; █ █ █ █ █ █ █ █
3053 .db %11010101,%01010101 ; ██ █ █ █ █ █ █ █
3054 .db %10101010,%10101010 ; █ █ █ █ █ █ █ █
3056 .db 16,7 ;armor ; .......:.......:
3057 .db %10000111,%11110000 ; █ ███████
3058 .db %10011000,%00001100 ; █ ██ ██
3059 .db %10110011,%11000110 ; █ ██ ████ ██
3060 .db %10110000,%11110110 ; █ ██ ████ ██
3061 .db %10110011,%11000110 ; █ ██ ████ ██
3062 .db %10011000,%00001100 ; █ ██ ██
3063 .db %10000111,%11110000 ; █ ███████
3065 .db 16,7 ;torpedo .......:.......:
3066 .db %10111000,%00010101 ; █ ███ █ █ █
3067 .db %10011100,%00010101 ; █ ███ █ █ █
3068 .db %10111000,%01001010 ; █ ███ █ █ █
3069 .db %10000000,%11101010 ; █ ███ █ █
3070 .db %11100001,%11100101 ; ███ ████ █ █
3071 .db %10011000,%11110101 ; █ ██ ████ █ █
3072 .db %11100110,%00110010 ; ███ ██ ██ █
3074 .db 16,7 ;bullets .......:.......:
3075 .db %10000000,%11000000 ; █ ██
3076 .db %10000011,%11100000 ; █ █████ ▒▒▒
3077 .db %10011000,%11000000 ; █ ██ ██ ▒▒▒
3078 .db %11111100,%00000000 ; ██████ ▒▒▒
3079 .db %10011000,%11000000 ; █ ██ ██ ▒▒▒
3080 .db %10000011,%11100000 ; █ █████ ▒▒▒
3081 .db %10000000,%11000000 ; █ ██
3083 .db 16,7 ;laser .......:.......:
3084 .db %10000000,%00000000 ; █
3085 .db %10110010,%10000000 ; █ ██ █ █
3086 .db %10111011,%00000000 ; █ ███ ██
3087 .db %10011101,%11111111 ; █ ███ █████████
3088 .db %10111011,%00000000 ; █ ███ ██
3089 .db %10110010,%10000000 ; █ ██ █ █
3090 .db %10000000,%00000000 ; █
3092 .db 16,7 ;multiple .......:.......:
3093 .db %10000011,%10000000 ; █ ███
3094 .db %10000001,%11100110 ; █ ████ ██
3095 .db %10000001,%11100000 ; █ ████
3096 .db %10000011,%10000000 ; █ ███
3097 .db %10011000,%00000000 ; █ ██
3098 .db %10111100,%11000011 ; █ ████ ██ ██
3099 .db %10011000,%00000000 ; █ ██
3102 .db 128,128,128,128,128,128,128 ;128 = %10000000
3104 ;---------------------------- texts -------------------------------------------
3106 txt_about: .db " v0.96.A30",127,"by Shiar",0
3107 txt_email: .db "shiar0@hotmail.com",0
3108 txt_menu1: .db "NEW GAME",0
3109 txt_menu2: .db "CONTINUE",0
3111 txt_level: .db "LEVEL ",0
3112 txt_gameover: .db "GAME OVER!",0
3113 txt_score: .db "Score",0
3114 txt_hiscore: .db "Hiscore",0
3115 txt_lives: .db "Lx0?",0
3117 txt_pressenter: .db "Enter to continue",0
3118 txt_teacher: .db "(2",Lpi,"*.95)/sin 13",0
3119 txt_teacherans: .db Lneg,"14.2063168184",0
3121 ;---------------------------- save data ---------------------------------------
3123 PutWhere .dw GRAPH_MEM ;where to put the wide sprites
3128 hiname .db "Shiar.96",0
3132 level .db $01 ;level number
3133 levelp .dw XLlevelsdata+4 ;pointer to level data
3134 pickuptimer .db $04 ;counts when to place a pickup
3138 your_occ .db $00 ;0=normal 1..16=exploding
3139 your_inv .db $00 ;invincibility left
3140 your_armor .db $0a ;HP left
3141 your_lives .db $03 ;
3143 your_weapon .db $02 ;laser avail: 0=no, 1=yes
3144 your_multiples .db $00 ;multiples present
3145 torp_occ .db $00 ;torp.state: 0=unavail 1=avail 2=presnt
3146 torp_pos .dw $0000 ;torpedo position (x,y)
3149 ;----------------------------- logo -------------------------------------------
3152 .db %11111111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%00001011,%11111111,%11111111,%11111111,%11111000
3153 .db %01111111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%00011011,%11111111,%11111111,%11111111,%11110000
3154 .db %00111111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%00111011,%11111111,%11111111,%11111111,%11100000
3155 .db %00011111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%01111011,%11111111,%11111111,%11111111,%11000000
3156 .db %00000000,%00000000,%00000001,%00011110,%00010000,%00000000,%10000001,%00011110,%00010000,%000000001,%00000000,%00001000,%01000000,%00000000,%00000000,%00000000
3157 .db %00000000,%00000000,%00000011,%00011110,%00110000,%00000001,%10000011,%00011110,%00110000,%000000011,%00000000,%00011000,%11000000,%00000000,%00000000,%00000000
3158 .db %00000000,%00000000,%00000111,%00011110,%01110000,%00000011,%10000111,%00011110,%01110000,%000000111,%00000000,%00111001,%11000000,%00000000,%00000000,%00000000
3159 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011,%11111111,%11000000,%00000000,%00000000
3160 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011,%11111111,%11000000,%00000000,%00000000
3161 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011,%11111111,%11000000,%00000000,%00000000
3162 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011,%11111111,%11000000,%00000000,%00000000
3163 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000,%00000011,%11000000,%00000000,%00000000
3164 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000,%00000011,%11000000,%00000000,%00000000
3165 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000,%00000011,%11000000,%00000000,%00000000
3166 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000,%00000011,%11000000,%00000000,%00000000
3167 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011,%11111111,%11000000,%00000111,%11010001
3168 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011,%11111111,%11000000,%00000001,%00011011
3169 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011,%11111111,%11000000,%00000001,%00010101
3170 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011,%11111111,%11000000,%00000001,%00010001
3172 ;----------------------------- end --------------------------------------------
3178 ;------------------------------------------------------------------------------
3180 ; 0.95.A22 -- 22.X.99 -- size 5321
3182 ; * total size of enemy-sprites can now be 510 bytes (space = doubled!)
3183 ; # bullets hit enemies correctly that aren't 6x6; even the 16x10 bosses!
3184 ; * at g/o or nextlevel checks for keys released instead of waiting abit
3185 ; + name stored with hiscore (max. 8 chars, Shiar.95 by default)
3186 ; + when entering hi-name DEL goes back one char (with check 4 no chars)
3187 ; # program is reloaded at start so some score-bugs solved! (_asapvar=0)
3188 ; * at death, upgrades and pickups AREN'T removed! (just armor=0)
3189 ; # bullet is not displayed after being removed anymore
3190 ; # armor-icon stays hilighted when armor is decreased
3191 ; * when stars move off screen, they are placed at a NEW y-pos!
3192 ; * the starting x-positions of stars are not random, so the stars are
3193 ; spread all over screen. y is still random and changes during game
3194 ; * make_random functions smaller and used by different procs
3195 ; # MAJOR BUG! a "random" value was placed somewhere in mem thus
3196 ; creating bugs like unexplained loss of armor and stuff! (I think)
3198 ; 0.96.A31 -- 31.X.99 -- size 4836 + 888
3200 ; # if you were hit when armor-icon selected, prog did weird stuff
3201 ; + armor-bar (shows armor as a black line left at bottom)
3202 ; # bugs involving armor-bar changing armor to a wrong value
3203 ; # YES!!! the saving-bugs were caused by mmldir: it reset all data
3204 ; at mem $8000, so data is now stored at asmexecram+6000 instead!
3205 ; * external levels. All leveldata is loaded from "nemesis0"-var
3206 ; * some optimization (like cal\ret>jp + unused code removed/shortened)
3207 ; * storyline is loaded from level-file (will be compressed later..)
3208 ; + story can be _between_ levels, not only at the start of a new game
3209 ; * "new game" and "continue" in main menu are swapped (new comes 1st)
3210 ; * enemy bullets can do more than one damage: differs per level
3211 ; * collision does 4 damage, ground does 5, you start with 12 armor
3212 ; # running the level-file no longer crashes your calc but just returns
3213 ; * you now move 1.5 pixels per frame! this way you can outrun enemies
3214 ; * hellofajob but enemy-data is now stored at one location in 6 bytes,
3215 ; instead of two 4-byte spaces 40 bytes apart! (cleaner code; faster)
3216 ; * ground/ceiling/stars are continued when at boss (c00l level 3 boss)
3219 ; + added - removed * changed # bug fixed