version 1.0: weapon updates, start ti-83 version
[nemesis.git] / nemesis.z80
1 ;-----------------------------------------------------------------------------
2 ;----------------------------  N E M E S I S  --------------------------------
3 ;------------------------------------------------ cool arcade-shoot-em-up-game
4
5 ; ---------  Version                   -                  1.01.314  ---------
6 ; ---------  Release Date              -             2002 March 14  ---------
7 ; ---------  Author(s)                 -                     Shiar  ---------
8 ; ---------  Email Address             -         nemesis@shiar.org  ---------
9 ; ---------  Web Page                  -             www.shiar.org  ---------
10 ; ---------  Description               -   cool shoot-em-up arcade  ---------
11 ; ---------  Where to get this game    -                 shiar.org  ---------
12 ; ---------  Other games by author(s)  -                     Wormy  ---------
13
14 ;   ----------------------------------------------------------------------
15 ;   --- This source should only be used for learning practises, do not ---
16 ;   --- alter it, and certainly never  distribute an altered version!! ---
17 ;   ----------------------------------------------------------------------
18
19 ;---------------------- nemesis.z80 start ------------------------------------
20
21  #define        TI86 ;TI83
22
23  #define        cal     call    ;just to make it harder for you to understand
24  #define        rcl     call    ;RemoteCaLl / RomCalL
25  #define        rjp     jp      ;RomJumP
26  #define        dnz     djnz    ;Dec&Jump while NonZero becomes Do w.Non-Zero
27  #define        psh     push    ; >:->
28
29 #ifdef TI83 ;-----------------------------------------------------------------
30 #include        "ion.inc"       ;standard TI-83 ROMcalls (Ion shell)
31
32  #define        halt    or a
33
34 scrwidth        = 12
35
36 #define         teacherkey      ;compiled with teacher key: 92 bytes extra
37
38 VIDEO_MEM       = plotsscreen
39 dispbuffer      = VIDEO_MEM     ;virtual screen (MUST be mod$400=0!!)
40
41 BUSY_OFF        = _indicatorOff
42 _curRow         = currow
43 _curCol         = curcol
44 _penCol         = pencol
45 ;_clrLCD        = _clrlcdf      ;clears screen
46 _clrScrn        = _clrscrf      ;also clears TEXT_MEM
47 _clrWindow      = _clrscrf
48 GET_KEY         = $4014         ;_getcsc
49 CONTRAST        = contrast
50 _dispahl        = _disphl
51 UNPACK_HL       = $4008         ;_divhlby10
52 CP_HL_DE        = _cphlde
53 Lpi             = $C4
54 Lneg            = $1A
55 K_DOWN          = 1
56 K_LEFT          = 2
57 K_RIGHT         = 3
58 K_UP            = 4
59 K_ENTER         = 9
60 K_DEL           = $20
61 K_ALPHA         = $30 ;48
62 K_F1            = $35 ;Y=
63 K_SECOND        = $36 ;54
64 K_EXIT          = $37 ;Mode
65 kEnter          = 5
66 kGrMenu         = 44
67
68 storepos        = saferam2      ;<1024 bytes needed to store things
69
70         .org progstart
71
72          ret
73          jr nc,init
74 Title:  .db "Nemesis 83 TEST by SHIAR",0
75 #endif ;----------------------------------------------------------------------
76
77
78 #ifdef TI85 ;-----------------------------------------------------------------
79 #include        "usgard.h"      ;usgard shell
80
81 scrwidth        = 16
82
83 ;#define        clearbuffer     ;clears the display buffer after usage
84 ;#define        fixkeys         ;fixes left+down bug: 47 bytes extra size
85 ;#define        teacherkey      ;compiled with teacher key: 92 bytes extra
86 ;#define        story           ;storyline shown (w/ neat effect): 871 bytes
87 ;#define        shiscore        ;save hiscore/savegame
88 ;#define        invertable
89
90 dispbuffer      = $8400 ;$C9FA  ;virtual screen (MUST be mod$400=0!!)
91                         ;8100-8C00
92 ;_clrWindow     = $4a86         ;_clrLCD and _clrScrn
93 ;_ex_ahl_bde    = $45f3         ;exchange values between AHL and BDE
94 ;_shracc                = $4383         ;like _shlacc but just the opposite :P
95 ;_dispahl       = $4a33         ;display value in ahl <100000 (cheap TI)
96 ;_asapvar       = $d6fc         ;our own variable name (likely "nemesis")
97
98 storepos        = TEXT_MEM      ;<1024 bytes needed to store things
99 saferam1        = DELC_MEM
100
101         .org 0
102 Title:  .db "Nemesis 85 Alpha"  ;Usgard description
103 ;       .db " - 4 Nunome",0     ;present
104         .db " by SHIAR",0       ;author
105 #endif ;----------------------------------------------------------------------
106
107
108 #ifdef TI86 ;-----------------------------------------------------------------
109 #include        "asm86.h"
110 #include        "ti86asm.inc"   ;standard ti86 romcalls
111 #include        "ti86abs.inc"   ;used to save hiscores and stuff
112
113 scrwidth        = 16
114
115 ;#define        clearbuffer     ;clears the display buffer after usage
116 #define         fixkeys         ;fixes left+down bug: 47 bytes extra size
117 #define         teacherkey      ;compiled with teacher key: 92 bytes extra
118 ;#define        story           ;storyline shown (w/ neat effect): 871 bytes
119 #define         shiscore        ;save hiscore/savegame
120 #define         invertable
121
122 dispbuffer      = $8400 ;$C9FA  ;virtual screen (MUST be mod$400=0!!)
123                         ;8100-8C00
124 _clrWindow      = $4a86         ;_clrLCD and _clrScrn
125 _ex_ahl_bde     = $45f3         ;exchange values between AHL and BDE
126 _shracc         = $4383         ;like _shlacc but just the opposite :P
127 _dispahl        = $4a33         ;display value in ahl <100000 (cheap TI)
128 _asapvar        = $d6fc         ;our own variable name (likely "nemesis")
129
130 storepos        = _asm_exec_ram+7800    ;<1024 bytes needed to store things
131                                         ;$F5C0..F9C0 (safe mem D748..FA6F)
132
133         .org _asm_exec_ram
134
135          nop                    ;hello yas/ase/rascall/whathever
136          jp init                ;here's the program, but first: a description
137         .dw $0001               ;description type 2 (description + YASicon)
138         .dw Title               ;pointer to description (all shells)
139         .dw Icon                ;pointer to YAS icon
140
141 Title:  .db "Nemesis v1.0.C21"  ;Ashell/Rascall/YAS/any shell description
142 ;       .db " - 4 Nunome",0     ;present
143         .db " by SHIAR",0       ;author
144
145 Icon:   .db 8,1                 ;icon for YAS: width = 1byte; height = 7bytes
146         .db %11100000           ; ███
147         .db %01111000           ;  ████
148         .db %00111110           ;   █████
149         .db %01111001           ;  ████  █
150         .db %00111110           ;   █████
151         .db %01111000           ;  ████
152         .db %11100000           ; ███             ;recommend 80x50 screen mode
153         .db 0                   ;YAS 0.92 compatibility
154 #endif ;----------------------------------------------------------------------
155
156 ;---------------------- in-game vars -----------------------------------------
157
158 just_fired      = storepos              ;  +0   ;counts how long a blast lasts
159 #ifdef shiscore
160 hiscorepos      = storepos              ;  +0   ;entering hiscore name
161 #endif
162
163 x               = storepos+1            ;  +1   ;your ship's position
164 y               = x+1                   ;  +2   ;your y-pos
165 firex           = y+1                   ;  +3   ;(1 byte)
166 firey           = firex+1               ;  +4   ;(1 byte)
167
168 eventleft       = firey+1               ;  +5   ;nr. of enemies still to come
169 level_enemy     = eventleft+1           ;  +6   ;enemy type
170 level_info      = level_enemy+1         ;  +7   ;ground (%0) present
171 spacespace      = level_info+1          ;  +8
172 stars1          = spacespace+1          ;  +9   ;slow stars byte  (<< %1)
173 stars2          = stars1+1              ; +10   ;fast stars byte (<<< %1)
174 groundpos       = stars2+1              ; +11   $10
175 nrstars1        = 10
176 starx1          = groundpos+16          ; +27   ;20
177 nrstars2        = 10
178 starx2          = starx1+(nrstars1*2)   ; +47   ;20
179
180 mm              = 4                             ;max. number of multiples
181 your_prevpos    = starx2+(nrstars2*2)   ; +67   ;14*mm+2 ;previous positions
182
183
184 enemies         = your_prevpos+(mm*14+4);+125   ;info about each enemy
185 enemysize       = 11                            ;infobytes per enemy
186 nrenemies       = 16                            ;max. nr of enemies
187
188 #ifdef TI86
189 ybullets        = enemies+(nrenemies*enemysize) ;60 bytes = 20(state,damg,x,y)
190 #else
191 ybullets        = saferam1
192 #endif
193 nrybuls         = 128                   ;+301
194 ebullets        = ybullets+(nrybuls*4)  ;+813   ;30 bytes = 10(state,x,y)
195 nrebuls         = 48
196 lvlenemies      = ebullets+(nrebuls*3)  ;-957
197
198 ;enemies:
199 ;       [HP64] [000000:HP left 00:(00=no enemy 01=exploding 1X=normal)]
200 ;       [ship sprite (DW!) or explosion frame] [x] [y] [movetype]
201 ;       [movecounter] [firecounter] [firefreq] [firetype]
202
203 ;---------------------------- save data --------------------------------------
204
205 ;#ifdef shiscore
206 storehi_start:
207 hiscore         .dw 0                   ;default hiscore
208 hiname          .db "by shiar",0,0      ;   "       "    name
209 storehi_end:
210 ;#endif
211
212 invertmode:      cpl ;/or a             ;saves B<>W mode setting        cpl
213
214 storesave_start:                        ;--SAVED GAME--                 defs:
215 your_ship       .dw spr_ship03          ;your sprite (^invertmode^)     sprs1
216 level           .db  4                  ;level number                   1
217 levelp          .dw level05             ;pointer to level data          lev00
218 pickuptimer     .db  4                  ;counts when to place a pickup  4
219 your_score      .dw  0                  ;current score                  0
220 your_pickup     .db  3                  ;pickups already picked up      0
221 your_occ        .db  0                  ;0=normal 1..16=exploding       0
222 your_shield     .db  0                  ;invincibility left             0
223 your_armor      .db 24                  ;HP left                        24
224 your_lives      .db  3                  ;lives left                     3
225 your_weapon     .db 3                   ;current weapon upgrade         0
226 your_multiples  .db  0                  ;multiples present              0
227 your_extra      .db  0                  ;extra beam present             0
228 hardcore        .db  0                  ;hardcore mode if non-0         0
229 storesave_end:
230
231 time2invert:    .db 0                   ;time until b<>w switch (0 at startup)
232 ;45+31=76
233 ;---------------------- init -------------------------------------------------
234
235 #ifdef fixkeys
236 int_handler:                    ;new interrupt proc
237         ex  af,af'              ;just af only (no need for exx)
238         in  a,($03)             ;read bit 3 port 3
239         bit 3,a                 ;is ON key pressed?
240         jp  z,$0039             ;no: np, return
241         res 0,a                 ;yes: then we have a problem (freeze), so...
242         out ($03),a             ;...mask the ON key interrupts!
243         jp  $0039               ;all done, return
244 int_end:                        ;(size 15 bytes)
245 #endif
246
247 init:   rcl BUSY_OFF            ;turns the run-indicator off, obviously
248 #ifdef TI83
249         ld  (iy+13),0
250         res 6,(iy+9)            ;TI-83 uses statmem
251         set textwrite,(iy+20)   ;write text to gbuf
252         rcl _clrLCD
253 #endif
254 #ifdef TI86
255         res 2,(iy+13)           ;don't scroll the screen
256         rcl _flushallmenus      ;remove TI-86 menus
257         rcl _clrScrn            ;clean the screen
258         ld  hl,$8200
259         ld  c,10
260 _clrmem:
261         ld  b,0
262 clrmem: ld  (hl),-1
263         inc hl
264         djnz clrmem
265         dec c
266         jr  nz,_clrmem
267 #endif
268
269 #ifdef fixkeys
270 FixKeys:                        ;fixes some key problems like left+down bug
271         im  1
272         ld  a,$D4
273         ld  bc,$0100
274         ld  h,a
275         ld  l,c                 ;ld hl,$D400 (user silent link routine space)
276         ld  d,a
277         ld  e,b                 ;ld de,$D401
278         dec a                   ;ld a,$D3
279         ld  (hl),a
280         ldir                    ;fill $D400-D500 with $D3s (slink/user on)
281         ld  hl,int_handler      ;new interrupt handler
282         ld  d,a
283         ld  e,a                 ;ld de,$D3D3
284         ld  bc,int_end-int_handler
285         ldir                    ;load new handler at ($D3D3)
286         inc a                   ;ld a,$D4
287         ld  i,a
288         im  2
289 #endif
290
291 ;---------------------- main menu --------------------------------------------
292
293 LogoPut:
294         xor a                   ;white bitmask (a=0)
295         ld  hl,logo_nemesis     ;from...
296         ld  de,VIDEO_MEM+scrwidth;...to one line from top
297 #ifdef TI86
298         ld  b,e                 ;ld b,16: one line
299 #else
300         ld  b,scrwidth
301 #endif
302 AboveLogo:
303         ld  (de),a              ;clear/n byte
304         inc de                  ;next
305         dnz AboveLogo           ;repeat for the first line
306         ld  bc,scrwidth*19      ;logo size
307         ldir                    ;display one line of logo
308
309         ld  hl,scrwidth*$33+VIDEO_MEM   ;$33 rows down
310         ld  b,scrwidth*7        ;draw black 7 lines
311         ld  a,%11111111         ;horizontal line mask
312 underline:
313         ld  (hl),a              ;draw one piece of the divider-line
314         inc hl                  ;move right (8 pixels = 1 byte)
315         dnz underline           ;repeat
316 #ifdef TI83
317         cal fastCopy            ;draw buffer on screen
318 #endif
319
320         ld  hl,_txt_email       ;at the very bottom of tha screen
321         ld  (_penCol),hl
322         ld  hl,txt_email        ;hey, my e-mail address so SEND ME SOMETHING!!
323         rcl _vputs              ;VERY important, so display in small font ?:}
324
325         set 3,(iy+5)            ;set white on black
326         ld  de,_txt_about       ;near the bottom of the screen
327         ld  (_penCol),de        ;hl=txt_email++=txt_about
328         rcl _vputs              ;display version + me
329         res 3,(iy+5)            ;return to default black on white
330
331 dispmenu:
332         ld  de,$0304
333         ld  (_curRow),de
334         ld  hl,txt_menu1        ;NEW GAME
335         rcl _puts
336         ld  de,$0305
337         ld  (_curRow),de
338         ld  hl,txt_menu2        ;CONTINUE GAME
339         rcl _puts
340
341 menuloop:
342         ld  a,0                 ;current menu item (0 or 1); 0 by default
343 menuitem =$-1
344         ld  h,$01               ;selector (*) x-coord. = 1
345         add a,4
346         ld  l,a                 ;y-coord. = sel menu item + 4 = 4/5
347         ld  (_curRow),hl        ;set position
348         ld  a,5                 ;'*'
349         rcl _putmap             ;mark selected menu item
350
351         ld  a,l                 ;y-pos 4/5
352         xor 1                   ;invert (4=5; 5=4)
353         ld  (_curRow),a         ;set new row position
354         ld  a,32                ;' ' (empty, just remove any * present)
355         rcl _putc
356
357         cal getsomekeys         ;read keys (z if enter/2nd pressed)
358         ld  hl,menuitem
359         jr  z,start_tha_freakin_game
360         cp  K_EXIT
361         jr  z,menuexit          ;exit goes to the g/o screen (first score=0)
362         cp  K_UP
363         jr  z,menuchange        ;up changes selected menu item
364         cp  K_DOWN              ;down as well
365         jr  nz,menuloop         ;anything else just loops
366 menuchange:
367         ld  a,(hl)              ;(menuitem)
368         xor 1                   ;0=1; 1=0
369         ld  (hl),a              ;set new menu item
370         jr  menuloop            ;continue looping
371
372 start_tha_freakin_game:
373         ld  a,(hl)              ;(menuitem)
374         dec a                   ;new game=0; so that gives -1 = NZ
375         jp  nz,New_game         ;NEW GAME
376         jp  samelevel           ;CONTINUE: game_main_loop
377
378 menuexit:
379         ld  hl,0                ;reset score
380         ld  (your_score),hl     ;(prevents hiscore while never played)
381         jp  game_over           ;and go to game over screen
382
383 do_invert:                      ;invert screen (b<>w)
384         psh hl
385         psh af                  ;can't destroy b
386         ld  hl,_invert
387         ld  a,$98
388         xor (hl)                ;$2F (cpl) <-> $B7 (or a)
389         ld  (hl),a
390         pop af
391         pop hl
392         ret
393
394 #ifdef invertable
395 mode_invert:
396         ld  hl,invertmode       ;change invert mode (will be stored)
397         ld  a,$98
398         xor (hl)                ;$2F (cpl) <-> $B7 (or a)
399         ld  (hl),a
400         ld  de,1
401         psh de                  ;size
402         psh hl                  ;dest (invertmode)
403         ld  hl,4+invertmode-_asm_exec_ram
404         psh hl                  ;src
405         jp  storesmtn
406 #endif
407
408 ;-----------------------------------------------------------------------------
409 ;---------------------- game loop --------------------------------------------
410 ;-----------------------------------------------------------------------------
411
412 game_main_loop:                 ;REPEATS FROM HERE EVERY FRAME
413         ld  hl,timer            ;update time
414         inc (hl)                ;increase by 1
415
416 Clear_screen:
417         ld  hl,dispbuffer       ;move from (hl) = top left
418         ld  (hl),0              ;first pixel will be copied all over the screen
419         ld  de,dispbuffer+1     ;(de) = next pixel, thus clearing whole screen
420         ld  bc,scrwidth*56-1    ;loop 896 times = (128/8) * (64-8 for scorebar)
421         ldir                    ;all clear!
422
423         ld  a,0                 ;current frame/turn 0-255
424 timer =$-1
425         and %11                 ;a=0 once every 4 turns
426         jr  z,movestarsdone     ;don't move stars once every 4 frames
427         cal movestars1          ;move the stars on the FRONT layer
428         cal movestars2          ;move the distant stars
429 movestarsdone:
430         ld  a,(stars1)          ;star positions (the missing byte...)
431         ld  b,nrstars1          ;how many stars? now we know.
432         ld  hl,starx1           ;points to the position of the stars
433         cal DisplayStars        ;display front layer stars
434         ld  a,(stars2)          ;weren't you paying attention five lines ago?
435         ld  b,nrstars2          ;that many?! whow!
436         ld  hl,starx2           ;and there they are
437         cal DisplayStars        ;use the same procedure to display back layer
438
439         ld  a,(level_info)      ;level info
440         rra                     ;ground present? (%1)
441         jr  nc,game_stuff       ;no, continue game
442         cal Handle_ground       ;scroll the ground and check if we're dead
443
444 game_stuff:
445         cal Handle_Ship         ;move you
446         ld  a,(your_occ)        ;are you 100% OK?
447         or  a                   ;a=0??
448         jr  nz,_gamestuff1      ;then don't check for movements/fires/...
449
450 check_keys:
451         ld  a,%10111111         ;function keys (MORE,EXIT,2ND,F1,F2,F3,F4,F5)
452         out (1),a               ;ask for them
453         nop \ nop               ;delay 8 clocks
454         in  a,(1)               ;gettem!
455
456 check_exitkey:
457         bit 6,a                 ;test bit 6 = exit-key = EXIT
458         jp  z,game_over         ;<exit> pressed, so be it
459 check_morekey:                  ;another unused label... poor compiler
460         bit 7,a                 ;test bit 7 = more-key = PAUSE
461         psh af
462         cal z,Pause             ;yes, go to pause
463         pop af
464
465 check_firekey:
466         bit 5,a                 ;test bit 5 = 2nd-key = FIRE
467         ld  hl,check_selkey     ;where to continue after executing Fire_bullet
468         psh hl                  ;push hl on stack (instead of cal Fire_bullet)
469         jp  z,Fire_bullet       ;fire smtn (bulletstaillasermultiples+stuff..)
470         pop hl                  ;no cal to Fire_bullet made, so pop stack
471         ld  hl,just_fired       ;no:
472         ld  (hl),5              ;able to fire (five turns = laser duration)
473 laserdur =$-1                   ;SMC laser duration
474
475 check_selkey:
476         ld  a,%01011111         ;look at first column of keys (ALPHA to STO)
477         out (1),a
478         in  a,(1)               ;our precious keys
479
480 #ifdef teacherkey               ;should we check for the teacherkey?
481         bit 6,a                 ;'bout the GRAPH key...
482         cal z,Teacher           ;you didn't _press_ it, did you?!?
483 #endif
484
485         rla                     ;test bit7 so we know f ALPHA has been pressed
486         cal nc,select           ;yeppy, select the currently selected upgrade
487
488         cal Enemies_hit         ;check for collision with enemies
489         cal inc_weapdamage
490
491 _gamestuff1:
492         cal Handle_enemies      ;move enemies
493
494         cal Handle_bullets      ;move your bullets + check for hits
495         cal Enemy_bullets       ;move enemy bullets
496
497         cal Level_event         ;insert enemies
498         cal Display_Screen      ;display all
499
500 #ifdef TI86
501 delay:
502         halt                    ;delay and preserve batteries :)
503 #else                           ;halt doesn't work on TI-83
504         ld  b,0
505 delay:
506         xor 1
507         and 1
508         jr  z,delay
509         dnz delay       
510 #endif
511         jp  game_main_loop      ;LOOP ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
512
513 ;------- weapon -------
514
515 inc_weapdamage:
516         ld  a,0
517 weapincs =$-1
518         inc a
519         cp  97                  ;max. 96 times (=96/16=6 increases)
520         ret nc                  ;return if already maxed
521         ld  (weapincs),a        ;save new incs
522
523         and %11110000           ;clear last 4 bits so no cf when rotating
524                                 ;btw: AND resets cf
525         rra                     ;rotate acting as shift (srl a) but just 1B
526         rra
527         rra
528         rra                     ;increase once just every 16 turns
529         ld  b,a                 ;times to increase
530 incthedamage:
531         add  a,1                ;increase damage for one increase
532 weapdaminc =$-1
533         dnz incthedamage        ;a=total increase damage
534         ld  b,1                 ;minimal damage
535 weapdamage =$-1
536         add a,b                 ;a=total damage
537         ld  (curweapdamage),a   ;safe the current damage
538
539
540 disp_charge:                    ;display charge bar
541 #ifdef TI86
542         ld  hl,(58*scrwidth)+VIDEO_MEM+3
543         ld  b,3                 ;bar width 3
544 #else
545         ld  hl,(58*scrwidth)+VIDEO_MEM+2
546         ld  b,2                 ;bar width 1.5
547 #endif
548 chargebarclr:
549         dec hl
550         ld  (hl),0              ;clear (previous) bar
551         dnz chargebarclr
552
553         ld  a,(weapincs)        ;load bar size (0-80)
554         srl a                   ;half the size (0-40)
555         srl a                   ;again half that size (0-20 pixels)
556 #ifdef TI83
557         srl a                   ;and again if 83 (smaller screen)
558 #endif
559         ld  c,a                 ;psh a
560         srl a                   ;/2
561         srl a                   ;/4
562         srl a                   ;/8: don't display last 3 bits of a (later)
563         jr  z,nochargebar       ;if a=0 then it would loop 256x so skip it
564         ld  b,a                 ;loop b=a times
565 chargebar:                      ;starting at ($39*16)+VIDEO_MEM
566         ld  (hl),%11111111      ;draw a piece of the bar
567         inc hl                  ;next position
568         dnz chargebar           ;loop it b times
569 nochargebar:
570         ld  a,c                 ;pop a
571         and %111                ;display last bits of chargebar
572         ret z                   ;if armor=0 then bit = %00000000 (don't disp)
573         ld  b,a                 ;into B
574         xor a                   ;bit = %00000000
575 chargebarbit:
576         scf                     ;set carry flag
577         rra                     ;rotates A right and sets bit 7 (c-flag)
578         dnz chargebarbit        ;repeat B times (so if B=6 then a=%11111100)
579 chargebarready:                 ;               (an if B=3 then a=%11100000)
580         ld  (hl),a              ;draw this last byte
581         ret
582
583 spr_bossA2:                     ;the following 51 bytes also function as the
584         .db 8,51                ; sprite for boss A2 (the fullscreen asteroid)
585
586 ;--------------------------- ground ------------------------------------------
587
588 Handle_ground:
589         ld  a,(timer)
590         and %111                ;once every 8 frames
591         jr  nz,Display_ground   ;otherwise skip the scroll
592         ld  bc,scrwidth-1       ;scroll all 16 bytes minus one (teh new byte)
593         ld  hl,groundpos+1      ;from..
594         ld  de,groundpos        ;to (one byte to the left)
595         ldir                    ;LoaDIncreaseRepeat = scroll!
596
597         ld  a,(groundpos+14)    ;last ground on right
598         ld  d,a                 ;as default ground
599         ld  hl,spacespace
600         ld  bc,$500             ;range=0..4
601         cal Random              ;a=0..4
602         dec a                   ;a=-1..3
603         dec a                   ;a=-2..2
604         ld  b,a
605         add a,(hl)              ;substract to spacesize
606         cp  128
607         jr  c,newground         ;if nothing left then don't change
608         ld  c,a
609         ld  a,d                 ;current grond height
610         add a,b                 ;add offset (2 higher/lower) => new position
611         or  a                   ;=0?
612         jr  z,newground         ;may not be 0 (=256)
613         cp  -10                 ;>246?
614         jr  nc,newground        ;and not be <0
615         ld  d,a
616         ld  (hl),c
617 newground:
618         ld  a,d
619         ld  (groundpos+15),a    ;save new byte on the right
620
621 Display_ground:
622         ld  b,scrwidth          ;screen width
623         ld  de,groundpos-1      ;height of current byte (previous actually)
624         psh de                  ;use later
625         ld  hl,dispbuffer+(56*scrwidth)-1 ;screen position
626         psh hl
627
628 groundloopright:
629         ld  c,b                 ;push b for groundloopup
630         pop hl \ inc hl         ;get screen position and go one right
631         pop de \ inc de         ;get height info and set to the next byte
632         psh de \ psh hl         ;save these for the next time
633         ld  a,(de)              ;height of current byte
634         ld  b,a                 ;save in b
635
636         ld  de,-scrwidth        ;to substract to go one line up
637         ld  a,%11111111         ;bitmask black
638 groundloopup:
639         ld  (hl),a              ;display black byte
640         add hl,de               ;go up (sbc must be used for 16-bit sub)
641         dnz groundloopup        ;and loop >groundpos< times
642
643         ld  b,c                 ;pop b used by groundloopup
644         dnz groundloopright     ;loop right for entire screen (16x)
645         pop hl \ pop hl         ;restore stack
646
647 CheckGround:                    ;check for collision with the ground
648         ld  a,(x)
649         srl a
650         srl a
651         srl a
652         inc a
653         ld  l,a
654         ld  h,0
655         ld  de,groundpos
656         add hl,de
657         ld  a,(y)
658         sub 57-7
659         neg
660         cp  (hl)
661         ret nc
662         ld  b,auch_ground
663         jp  damage_you
664
665 ;--------------------------- move stars --------------------------------------
666
667 DisplayStars:                   ;inputs: hl=starx# a=stars# b=nrstars#
668         ld  e,(hl)
669         inc hl
670         ld  d,(hl)
671         ld  (de),a
672         inc hl
673         dnz DisplayStars
674         ret                     ;let's comment this: returns
675
676 movestars2:
677         ld  ix,starx2
678         ld  a,(stars2)
679         rlca                    ;move bits (star) left
680         ld  (stars2),a
681         ret nc                  ;if star didn't went from left to right bit
682         ld  b,nrstars2          ;otherwise move all stars one byte left
683         jr  movestars_loop
684
685 movestars1:
686         ld  ix,starx1
687         ld  a,(timer)
688         rra
689         ld  a,(stars1)
690         ret c                   ;once every other turn...
691         rlca
692         ld  (stars1),a
693         ret nc
694         ld  b,nrstars1
695
696 movestars_loop:
697         ld  h,(ix+1)
698         ld  l,(ix)              ;star (ix) pos in hl
699         dec hl                  ;one byte left (hl--)
700
701         ld  a,dispbuffer/256-1  ;screen high byte minus one (it may be equal)
702         cp  h                   ;compare w/ star high byte
703         jr  c,newstarok         ;screen<star: still on screen
704         cal RandomY             ;otherwise create new position hl
705
706 newstarok:
707         ld  (ix),l              ;save star's new position (ix)=hl
708         ld  (ix+1),h
709         inc ix \ inc ix         ;next star (2 bytes/star)
710         dnz movestars_loop      ;repeat for each star
711         ret                     ;...here's another comment... :P
712
713 ;--------------------------- pause -------------------------------------------
714
715 Pause:
716         ld  hl,_txt_pause
717         ld  (_penCol),hl
718         ld  hl,txt_pause
719         rcl _vputs              ;display small font
720         ld  hl,_txt_pressenter  ;top centered
721         ld  (_curRow),hl
722         ld  hl,txt_pressenter   ;"Enter to continue"
723         rcl _puts               ;display message
724 pause:
725         cal getsomekeys         ;GET_KEY w/ halts and checks for enter
726         ret z                   ;enter/second pressed: continue game
727 #ifdef invertable
728         cp  K_F1                ;F1 pressed?
729         jr  nz,notinvert
730         cal do_invert           ;if so then change invert screen (AF saved)
731         cal mode_invert         ;and screen mode (will be saved)
732 notinvert:
733 #endif
734         ld  hl,CONTRAST         ;contrast setting (0-31)
735         ld  b,(hl)              ;load contrast into b
736         cp  K_UP                ;+ key changes contrast up
737         jr  nz,contr_not_up
738         inc b                   ;increase contrast
739         jr  setcontrast         ;set
740 contr_not_up:
741         cp  K_DOWN              ;- key
742         jr  nz,pause            ;nope: loop
743         dec b                   ;decrease contrast
744 setcontrast:
745         ld  a,b
746         ld  (hl),a
747         out (2),a               ;and set it
748         cal releasekeys
749         jr  pause               ;and loop
750
751 ;--------------------------- teacher -----------------------------------------
752
753 #ifdef teacherkey               ;can be disabled to save space if not needed
754 Teacher:
755         ld  (iy+12),5           ;enable flashing cursor
756         rcl _clrWindow          ;top left
757         ld  hl,txt_teacher
758         rcl _puts               ;display message
759         cal releasekeys
760
761 teacherloop:
762         rcl _getkey             ;enter low-power mode and wait for key
763         cp  kEnter              ;enter pressed?
764         jr  z,teacherans
765         cp  kGrMenu             ;keypressed = graph?
766         jr  nz,teacherloop      ;no, wait some more
767
768         ld  (iy+12),0           ;disable cursor
769         cal releasekeys
770         jp  disp_icons          ;+ret
771
772 teacherans:                     ;enter displays the answer
773         ld  a,' '               ;the cursor could still be displayed (█)
774         rcl _putc               ;so remove it by displaying a ' ' over it
775
776         ld  hl,$0701
777         ld  (_curRow),hl        ;below the equation, aligned right
778         ld  hl,txt_teacherans   ;the answer text
779         rcl _puts               ;display
780         jr  teacherloop         ;and continue loop
781 #endif
782
783 ;--------------------------- exit --------------------------------------------
784
785 quit:
786 #ifdef fixkeys
787         im  1                   ;release keyfix procedure
788 #endif
789 #ifdef TI86
790         xor a
791         ld (_asapvar+1),a       ;next Asm( run will reload the program
792         res 5,(iy)              ;don't display "Done" in TI-OS :P
793         set 2,(iy+13)           ;set back screen scrolling again
794 #endif
795 #ifdef TI83
796         res 7,(iy+20)           ;_vputs will now write directly to LCD again
797         set 6,(iy+9)            ;finished with statmem
798 #endif
799 #ifdef clearbuffer              ;should we clear the display buffer?
800         ld  hl,dispbuffer       ;graph-screen location
801         ld  de,dispbuffer+1
802         ld  (hl),a              ;set to 0 (zero, nothing, nada, empty..)
803         ld  bc,1024-1           ;do it 1024 times = entire screen
804         ldir                    ;load that first 0 into the entire area
805 #endif
806         jp  _clrWindow          ;as _clrLCD but also clears TEXT_MEM (like the
807                                 ;_clrScrn) AND also executes _homeup and ret
808
809 ;--------------------------- display -----------------------------------------
810
811 Display_Screen:
812 #ifdef TI83
813 fastCopy:
814         jp  ionFastCopy
815         ld      a,$80           ; 7
816         out     ($10),a         ; 11
817         ld      hl,dispbuffer+2-16-(-(16*64)+1)    ; 10
818         ld      a,$20           ; 7
819         ld      c,a             ; 4     ; 43
820 fastCopyAgain:
821         ld      b,64            ; 7
822         inc     c               ; 4
823         ld      de,-(16*64)+1   ; 10
824         out     ($10),a         ; 11
825         add     hl,de           ; 11
826         ld      de,15           ; 10
827 fastCopyLoop:
828         add     hl,de           ; 11
829         inc     hl              ; 6
830         ret     c               ; 5
831         ld      a,(hl)          ; 7
832         out     ($11),a         ; 11
833         dnz     fastCopyLoop    ; 13/8  ; 3392
834         ld      a,c             ; 4
835         cp      $2B+1           ; 7
836         jr      nz,fastCopyAgain; 12/7
837         ret     ; 11    ; 18
838
839 #endif
840         ld  hl,dispbuffer       ;from buffer (top left)
841         ld  de,VIDEO_MEM        ;to real screen (top left)
842         ld  c,56                ;display height = 64 bytes (minus 8 for bar)
843 displayloop:
844         ld  b,16                ;display width = 16 bytes (16*8bits=256pixels)
845 displaytloop:
846         ld  a,(hl)              ;copy byte from (hl)
847 _invert:                        ;SMC: cpl <-> or a
848         cpl                     ;xor $ff: invert byte (white<=>black)
849         ld  (de),a              ;to (de)
850         inc hl \ inc de         ;next byte
851         dnz displaytloop        ;16x hl >> de
852         dec c                   ;next line
853         jr  nz,displayloop      ;loop 56x
854
855         ld  hl,time2invert
856         ld  a,(hl)
857         or  a                   ;(time2invert)=0:
858         jr  z,noinvert          ; do nothing
859         dec a                   ;otherwise decrease
860         cal z,do_invert         ;if it became 0 then invert
861         ld  (hl),a              ;save new value
862 noinvert:
863
864         ld  hl,$396b            ;Display Score
865         ld  (_penCol),hl        ;bottom right of screen
866         ld  hl,(your_score)
867
868 _D_HL_DECI:                     ;------- display 5-digit value -------
869         ld  de,savestr+4        ;savenr saves number string
870         ld  b,5                 ;five digits
871 ldhld:  rcl UNPACK_HL           ;one digit of hl
872         add a,'0'               ;make number
873         ld  (de),a              ;save into savenr
874         dec de                  ;point to next digit
875         dnz ldhld               ;repeat for all digits
876
877         ld  hl,savestr          ;we (the program) saved the value righthere
878         jp  _vputs              ;the only thing left to do is to display it
879
880 savestr:                        ;@here the score will be stored
881         .db "00000",0           ;don't worry, it's just temporary
882
883 ;------------------------- handle ship ---------------------------------------
884
885 Handle_Ship:
886         ld  a,(your_occ)        ;are
887         or  a                   ;you
888         jr  z,ok                ;ok?
889
890         inc a                   ;no! next (explosion)frame
891         ld  (your_occ),a        ;save
892
893         cp  63+1                ;last explosion frame?
894         jp  c,exploding_you     ;not yet: display explosion
895         cp  64+16               ;delay finished?
896         ret nz                  ;no, don't display anything (&return)
897         pop hl                  ;restore stack (cuzzof call)
898         jp  z,You_die           ;yes = game over
899
900 ;----move----
901 ok:                             ;we are
902         ld  a,%01111110         ;get arrow keys
903         out (1),a               ;it's cold outside
904         ld  hl,y                ;instead of nop\nop do something usefull
905         in  a,(1)               ;come back in
906
907         ld  b,a                 ;psh a (keys)
908         xor -1                  ;inverted a: 0 if arrow-key has been pressed
909         ld  a,(your_multiples)          ;(btw: CPL doesn't set any flags)
910         res 7,a                 ;reset move bit (no flags changed)
911         jr  z,adv_ok            ;if so, leave the multiples where they are
912         set 7,a                 ;set move bit
913 adv_ok: ld  (your_multiples),a
914
915         ld  a,(timer)           ;framecounter
916         and %1                  ;switches 0<>1 each frame
917         inc a                   ;a = 1 or 2 (1.5 avg)
918         ld  c,a                 ;c = your_speed
919
920         ld  a,b                 ;pop a (keys)
921         rra                     ;rotate right (put last bit in c)
922         ld  b,a                 ;we need a later
923
924         jr  c,no_down
925         ld  a,(hl)
926         add a,c
927         cp  50                  ;56-6 = bottom of screen
928         jr  nc,no_down
929         ld  (hl),a
930 no_down:
931         dec hl
932         rr  b                   ;because we now use b, it's rr instead of rra
933         jr  c,no_left
934         ld  a,(hl)
935         sub c                   ;<dec a> doesn't affect c-flag
936         jr  c,no_left           ;-1 = left side
937         ld  (hl),a
938 no_left:
939         rr  b
940         jr  c,no_right
941         ld  a,(hl)
942         add a,c
943         cp  122                 ;128-6 = right side
944         jr  nc,no_right
945         ld  (hl),a
946 no_right:
947         ld  d,(hl)              ;d=x
948         inc hl
949         rr  b
950         jr  c,no_up
951         ld  a,(hl)
952         sub c                   ;<dec a> doesn't affect carry-flag
953         jr  c,no_up             ;-1 = top of screen
954         ld  (hl),a              ;save new y
955
956 no_up:  ld  e,(hl)              ;e=y
957         ld  ix,spr_ship01       ;normal ship sprite
958 your_shipspr =$-2
959         ld  hl,your_shield      ;shielded?
960         ld  a,(hl)              ;load time in a
961         or  a                   ;is it 0?
962         jr  z,disp_ship         ;yes so ship = normal (display \ continue)
963
964         ld  a,(timer)           ;load frame nr.
965         and %00000111           ;a=0 once every four frames
966         jr  nz,not_time         ;a<>0 = not time to update counter
967         dec (hl)                ;decrease inv-time left
968 not_time:
969         and %00000100           ;a switches 0<->1 every 2 frames
970         jr  z,disp_ship         ;show normal ship
971 inv_flicker:
972         ld  bc,spr_ship01i-spr_ship01
973         add ix,bc               ;display invulnerable ship
974 disp_ship:
975         cal safeputsprite       ;display your ship; save de
976
977 ;----multiples----
978
979 handle_multiples:
980         ld  a,(your_multiples)  ;do you have multiples
981         ld  b,a                 ;save a for 2nd check
982         and %1111               ;no? (last four bits = nr of multiples)
983         ret z                   ;then don't handle them either
984         bit 7,b                 ;move the multiples??? (=move bit set?)
985         jr  z,mult_adv          ;nope, just let them (saves (y)in y, (x)in x)
986
987         psh de                  ;current position = needed later
988         ld  hl,mm*14+1+your_prevpos     ;previous positions
989         ld  de,mm*14+3+your_prevpos     ;move all positions one back
990         ld  bc,mm*14+2
991         lddr                    ;change 0-57 -> 2-59 (if mm=4 that is)
992         inc hl                  ;your_prevpos+0
993         pop de
994         ld  (hl),d              ;x-pos
995         inc hl                  ;=current position
996         ld  (hl),e              ;y-pos
997
998 mult_adv:
999         ld  ix,spr_multiple     ;normal sprite
1000         ld  hl,timer
1001         bit 3,(hl)              ;change sprites every 8 turns
1002         jr  z,disp_multiples
1003         ld  ix,spr_multiple2    ;second sprite
1004 disp_multiples:
1005         ld  hl,your_prevpos+16  ;first pos.
1006 dispmultiplesloop:
1007         psh af
1008         psh hl
1009         ld  d,(hl)              ;load coords
1010         inc hl
1011         ld  e,(hl)
1012         psh ix
1013         cal putsprite           ;display
1014         pop ix                  ;same sprite next time ;)
1015         pop hl
1016         ld  de,14
1017         add hl,de               ;next multiple
1018         pop af                  ;counter
1019         dec a
1020         ret z                   ;return if all done
1021         jr  dispmultiplesloop   ;loop
1022
1023 ;----explode----
1024
1025 exploding_you:
1026         srl a                   ;half the framerate
1027         srl a                   ;and half that framerate
1028         ld  hl,x-1
1029         ld  ix,spr_yexplosion   ;base sprite
1030
1031 explosion_stuff:                ;in:a=frame*2+(0 to 1); (hl)=xpos-- ix=sprite
1032         and %11111110
1033         add a,a
1034         add a,a                 ;frame*8
1035         ld  c,a
1036         ld  b,0                 ;bc=a
1037         add ix,bc               ;go to correct sprite (each spr. is 8 bytes)
1038         inc hl                  ;@x
1039         ld  d,(hl)              ;load xpos
1040         inc hl                  ;@y
1041         ld  e,(hl)              ;and y
1042         jp  putsprite           ;and display it too
1043
1044 ;----hit----
1045
1046 damage_you:                     ;damages you B points
1047         ld  a,(your_occ)        ;return if already dead (prevents exploding
1048         or  a                   ; twice, or stucking in exploding state)
1049         ret nz                  ;0 = you're normal
1050
1051         ld  a,(hardcore)        ;hardcore mode?
1052         or  a
1053         jr  z,damageok          ;0 = no  = don't modify
1054 ;       sla b                   ;1 = yes = double tha damage (b shifted left)
1055         .db $CB,$30     ;sll b  ;damage=2b|1 (CB3r = unsupported SLL r)
1056 damageok:
1057         ld  a,(your_shield)     ;shield left?
1058         or  a
1059         jr  z,dothadamage       ;no shield
1060         srl b                   ;shield: half the damage
1061 dothadamage:
1062         ld  hl,time2invert
1063         xor a                   ;a=0
1064         cp  (hl)                ;not already inverted?
1065         cal z,do_invert         ;then invert screen
1066         ld  (hl),2              ;change back 2 frames from now
1067
1068         ld  hl,your_armor       ;armor left
1069         ld  a,(hl)              ;load hp in A
1070         sub b                   ;decrease hp by B
1071         jr  nc,newarmor         ;>=0hp left so don't explode
1072         ld  a,%01               ;occ %xxxxxx01 = explode
1073         ld  (your_occ),a        ;too bad, you're dead meat
1074 newarmor:
1075         ld  (hl),a              ;save decreased hp
1076         jp  disp_armor          ;and display new value
1077
1078 ;------------------------- place multiples -----------------------------------
1079
1080 Place_multiples:
1081         ld  hl,your_prevpos     ;place all previous positions
1082         ld  b,mm*7+2            ;all saved positions of them (14 per multiple)
1083 place_multiples:
1084         ld  (hl),e              ;set prev-x to d
1085         inc hl                  ;next
1086         ld  (hl),d              ;set prev-y to e
1087         inc hl                  ;next
1088         dnz place_multiples     ;repeat
1089         ret
1090
1091 ;------------------------- select upgrade ------------------------------------
1092
1093 inc_armor:
1094         ld  a,(your_armor)      ;load current armor
1095         cp  maxarmor-5          ;may not become >=maxarmor
1096         jr  c,doincarmor        ;ok then just add 6
1097         ld  a,maxarmor-6        ;set to maximum (6 will be added below)
1098 doincarmor:
1099         add a,6                 ;add 6 to armor
1100         ld  (your_armor),a      ;change armor
1101         ret
1102
1103 select:
1104         ld  de,your_weapon      ;current weapon, required for most selections
1105         ld  hl,your_pickup      ;select pickups
1106         ld  a,(hl)              ;load pickups taken so far
1107         dec a                   ;is it 1?
1108         ret m                   ;return if it's 0 (no pickups)
1109
1110         ld  (hl),0              ;reset pickups
1111         jr  nz,selectlaser      ;no, carry on again
1112 selectbeam:
1113         ld  a,(de)              ;(your_weapon)
1114         inc a                   ;next
1115         cp  maxweapon
1116         jr  c,selectedbeam      ;weapon OK
1117         jr  z,disp_icons        ;weapon maxed out
1118         xor a                   ;laser was selected: set to first weapon
1119 selectedbeam:
1120         ld  (de),a              ;set new weapon
1121         cal loadweapon          ;load it (damage and stuff)
1122         jr  disp_icons          ;display n return
1123 selectlaser:
1124         dec a                   ;is it 2?
1125         jr  nz,selectextra      ;no, carry on
1126         ld  (your_extra),a      ;no extra beams (tailbeam/up-double)
1127         ld  a,(de)              ;(your_weapon)
1128         cp  maxweapon           ;upgrade from bullet?
1129         jr  nc,upgradelaser     ;nope, just upgrade
1130         ld  a,maxweapon-1       ;yes, set laser #1
1131 upgradelaser:
1132         inc a                   ;next laser
1133         cp  maxlaser
1134         jr  nc,disp_icons       ;laser maxed out
1135         ld  (de),a
1136         cal loadweapon
1137         jr  disp_icons          ;display + return
1138 selectextra:
1139 ;       ld  a,(de)              ;(your_weapon)
1140 ;       cp  maxweapon+1         ;laser or beams?
1141 ;       jr  c,selectXbeam       ;if beamweap then no multiples but extra beam
1142         ld  hl,your_multiples
1143         ld  a,(hl)              ;multiples you already got
1144         and %1111               ;reset movebit so (your_multiples)=real value
1145         inc a                   ;one more
1146         cp  mm+1
1147         jr  nc,enoughmultiples  ;maxed out
1148         ld  (hl),a
1149 enoughmultiples:
1150         ld  de,(x)
1151         dec a                   ;if this is your first multiple then...
1152         cal z,Place_multiples   ;reset multiples positions
1153 ;       jr  disp_icons          ;display, return
1154 ;selectXbeam:
1155 ;       ld  a,1                 ;updouble
1156 ;       ld  (your_extra),a      ;ready extra beam
1157 ;       jr  disp_icons          ;display 'n return
1158
1159 ;--------------------------- show icon ---------------------------------------
1160
1161 disp_icons:                     ;destroyes: abcdehlix
1162 #ifdef TI86 ;-------86
1163
1164         ld  a,VIDEO_MEM/$400    ;directly on screen
1165         ld  (PutWhere),a        ;place icons at normal screen
1166         ld  hl,VIDEO_MEM+(scrwidth*56);56 rows down = eight rows from bottom
1167         ld  b,scrwidth          ;draw 16x (screen width)
1168         ld  a,%11111111         ;horizontal line mask
1169         cal drawline            ;draw divider-line
1170
1171         ld  b,scrwidth*7        ;draw 16x (screen width) 7x (height)
1172         xor a                   ;blank line mask
1173         cal drawline            ;clear scorebar
1174
1175 disp_lives:
1176         ld  de,$003C            ;(0,4)
1177         ld  a,(your_lives)      ;nr of lives
1178         or  a
1179         jr  z,displivesdone     ;no lives
1180         ld  b,a
1181 displivesloop:
1182         psh bc
1183         ld  ix,spr_lship
1184         cal safeputsprite       ;put li'l ship
1185         ld  a,lshipsize+1
1186         add a,d
1187         ld  d,a                 ;x=x+5
1188         pop bc
1189         dnz displivesloop       ;one ship per life
1190 displivesdone:
1191         cal disp_armor          ;display bar
1192
1193         ld  ix,spr_icon00       ;emptyIcon
1194         ld  a,(your_weapon)     ;ur weapon
1195         cp  maxweapon           ;bullets?
1196         psh af                  ;a=(your_weapon); cf=bullets
1197         jr  nc,no_bullets       ;=laser
1198         ld  hl,$3945            ;position to display bullet-type digit
1199         inc a                   ;1 = weapon #1 (=0)
1200         ld  (_penCol),hl        ;set location
1201         add a,'0'               ;make digit
1202         rcl _vputmap            ;display char
1203         ld  ix,spr_icon04       ;bulletIcon
1204 no_bullets:
1205         ld  de,$3939            ;icon #2
1206         cal putwidesprite       ;(beamweap)
1207
1208         ld  ix,spr_icon00
1209         pop af                  ;ld a,(your_weapon) \ cp maxweapon
1210         jr  c,no_laser          ;popped carry
1211         ld  hl,$3955            ;position to display laser-type digit
1212         ld  (_penCol),hl        ;set location
1213         sub maxweapon-1         ;1 = laser #1 (=maxweapon)
1214         add a,'0'               ;make digit
1215         rcl _vputmap            ;display char
1216         ld  ix,spr_icon03       ;laserIcon
1217 no_laser:
1218         ld  de,$4939            ;icon #1
1219         cal putwidesprite       ;display icon (laser)
1220
1221         ld  ix,spr_icon00       ;emptyIcon
1222         ld  a,(your_multiples)  ;number of multiples
1223         and %111                ;<8
1224         jr  z,no_multiples      ;none (empty)
1225         ld  ix,spr_icon05       ;multiples-icon
1226 no_multiples:                   ;no multiples
1227         ld  de,$5939            ;icon #3
1228         cal putwidesprite
1229
1230         ld  ix,spr_dividerline
1231         ld  de,$6939
1232         cal putwidesprite
1233
1234         ld  a,(your_pickup)     ;pickups taken
1235         add a,a                 ;picks*2 (sets z-flag)
1236         jr  z,iconsdone         ;return if no pickups
1237         add a,a                 ;picks*4
1238         add a,a                 ;picks*8
1239         add a,a                 ;picks*$10
1240         add a,$29               ;add 29h
1241         ld  d,a                 ;y-pos = picks * $10 + $29 (3a,4a,5a)
1242         ld  e,$39               ;x-pos = bottom (3a39,4a39,5a39)
1243
1244         ld  ix,spr_icon
1245         cal putwidesprite
1246 iconsdone:
1247         ld  a,dispbuffer/$400   ;normal game-screen
1248         ld  (PutWhere),a        ;set sprite-position to normal screen
1249         jp  disp_charge         ;display weapon charge bar
1250
1251 #else ;-------------83
1252
1253         ld  hl,VIDEO_MEM+(scrwidth*56);56 rows down = eight rows from bottom
1254         ld  b,scrwidth          ;draw 12x (screen width)
1255         ld  a,%11111111         ;horizontal line mask
1256         cal drawline            ;draw divider-line
1257
1258         ld  b,scrwidth*7        ;draw 12x (screen width) 7x (height)
1259         xor a                   ;blank line mask
1260         cal drawline            ;clear scorebar
1261
1262 disp_lives:
1263         ld  de,$003C            ;(0,4)
1264         ld  a,(your_lives)      ;nr of lives
1265         or  a
1266         jr  z,displivesdone     ;no lives
1267         ld  b,a
1268 displivesloop:
1269         psh bc
1270         ld  ix,spr_lship
1271         cal safeputsprite       ;put li'l ship
1272         ld  a,lshipsize+1
1273         add a,d
1274         ld  d,a                 ;x=x+5
1275         pop bc
1276         dnz displivesloop       ;one ship per life
1277 displivesdone:
1278         cal disp_armor          ;display bar
1279
1280         ld  ix,spr_icon00       ;emptyIcon
1281         ld  a,(your_weapon)     ;ur weapon
1282         cp  maxweapon           ;bullets?
1283         psh af                  ;a=(your_weapon); cf=bullets
1284         jr  nc,no_bullets       ;=laser
1285         ld  hl,$3935            ;position to display bullet-type digit
1286         inc a                   ;1 = weapon #1 (=0)
1287         ld  (_penCol),hl        ;set location
1288         add a,'0'               ;make digit
1289         rcl _vputmap            ;display char
1290         ld  ix,spr_icon04       ;bulletIcon
1291 no_bullets:
1292         ld  de,$2F39            ;icon #2
1293         cal putwidesprite       ;(beamweap)
1294
1295         ld  ix,spr_icon00
1296         pop af                  ;ld a,(your_weapon) \ cp maxweapon
1297         jr  c,no_laser          ;popped carry
1298         ld  hl,$393F            ;position to display laser-type digit
1299         ld  (_penCol),hl        ;set location
1300         sub maxweapon-1         ;1 = laser #1 (=maxweapon)
1301         add a,'0'               ;make digit
1302         rcl _vputmap            ;display char
1303         ld  ix,spr_icon03       ;laserIcon
1304 no_laser:
1305         ld  de,$3939            ;icon #1
1306         cal putwidesprite       ;display icon (laser)
1307
1308         ld  ix,spr_icon00       ;emptyIcon
1309         ld  a,(your_multiples)  ;number of multiples
1310         and %111                ;<8
1311         jr  z,no_multiples      ;none (empty)
1312         ld  ix,spr_icon05       ;multiples-icon
1313 no_multiples:                   ;no multiples
1314         ld  de,$4339            ;icon #3
1315         cal putwidesprite
1316
1317         ld  ix,spr_dividerline
1318         ld  de,$4D39
1319         cal putwidesprite
1320
1321         ld  a,(your_pickup)     ;pickups taken
1322         add a,a                 ;picks*2 (sets z-flag)
1323         ld  e,a                 ;save 2*picks
1324         jr  z,iconsdone         ;return if no pickups
1325         add a,a                 ;picks*4
1326         add a,a                 ;picks*8
1327         add a,e                 ;picks*10 (8+2=10)
1328         add a,$26               ;add 26h
1329         ld  d,a                 ;y-pos = picks * 10 + $29 (3a,45,4e)
1330         ld  e,$39               ;x-pos = bottom (3a39,4539,4e39)
1331
1332         ld  ix,spr_icon
1333         cal putwidesprite
1334 iconsdone:
1335         jp  disp_charge         ;display weapon charge bar
1336
1337 #endif ;------------^^
1338
1339 drawline:
1340         ld  (hl),a              ;draw one piece of the divider-line
1341         inc hl                  ;move right (8 pixels = 1 byte)
1342         dnz drawline            ;repeat (16bytes * 8pixels =128= screen width)
1343         ret
1344
1345
1346 disp_armor:
1347         ld  de,scrwidth         ;line size
1348 #ifdef TI86
1349         ld  hl,VIDEO_MEM+(58*scrwidth)+6
1350 #else
1351         ld  hl,VIDEO_MEM+(58*scrwidth)+5
1352 #endif
1353         ld  a,(your_armor)      ;load your armor (<maxarmor)
1354         srl a                   ;divide by 2 (barsize halved)
1355         psh af
1356         and %111                ;display last bits of armor
1357         jr  z,armorbarbitok     ;if b=0 then prevent looping 256x
1358         ld  b,a                 ;into B
1359         xor a                   ;bit = %00000000
1360 armorbarbit:
1361         scf                     ;set carry flag
1362         rla                     ;rotates A left and sets bit 0 (c-flag)
1363         dnz armorbarbit         ;repeat B times (so if B=6 then a=%00111111)
1364 armorbarbitok:                  ;               (an if B=3 then a=%00000111)
1365         ld  c,a                 ;save last bit in c
1366         pop af                  ;now we'll make the byte
1367         and %11111000           ;clear last three bits
1368         rra                     ;so we can use rotate instead of shift right
1369         rra                     ;which saves 3(-2) bytes and speed
1370         rra                     ;/8: don't display last 3 bits of a (later)
1371
1372         ld  b,5                 ;bar height
1373 armorbarloop1:
1374         psh bc                  ;yloop counter
1375         psh hl                  ;begin x-position
1376         ld  b,a                 ;loop b=a times per line
1377         or  a                   ;<1 bytes
1378         jr  z,lastarmorbit      ;then don't display bytes (would be 256x)
1379 armorbarbyte:
1380         ld  (hl),%11111111      ;draw a piece of the bar
1381         dec hl                  ;next position
1382         dnz armorbarbyte        ;loop it b times
1383 lastarmorbit:
1384         ld  (hl),c              ;draw the last byte
1385         dec hl
1386         ld  (hl),0              ;empty byte before to remove any remainders
1387         pop hl                  ;recall first byte
1388         add hl,de               ;one down
1389         pop bc                  ;recall yloop-counter
1390         dnz armorbarloop1       ;display again
1391
1392 #ifdef TI86
1393         ld  hl,(56*scrwidth)+VIDEO_MEM+7
1394 #else
1395         ld  hl,(56*scrwidth)+VIDEO_MEM+6
1396 #endif
1397         ld  a,%01010101
1398 armorbarY:
1399         cal drawbarrow          ;display "grey" mask
1400         cal drawbarrow          ;display "grey" mask
1401         add hl,de
1402         add hl,de
1403         add hl,de
1404         cal drawbarrow
1405 drawbarrow:                     ;ORs an entire row with A
1406         add hl,de               ;one down
1407         ld  b,4                 ;four bytes right
1408         psh hl
1409 armorbarX:
1410         dec hl                  ;next byte
1411         psh af
1412         or  (hl)
1413         ld  (hl),a              ;clear
1414         pop af
1415         dnz armorbarX           ;4x
1416         pop hl                  ;old position
1417         ret
1418
1419 ;------------------------- fire bullet ---------------------------------------
1420
1421 fire_multiple:
1422         psh af
1423         psh ix                  ;save ix for next fire
1424         cal fireany             ;fire from multiple position
1425         pop ix                  ;saving ix is much faster than recalculating
1426         pop af                  ;number of multiples
1427         dec a                   ;one just displayed
1428         pop hl                  ;ret
1429         ret z                   ;ret2 if none left
1430         jp  (hl)                ;real ret
1431
1432 fire_multiples:
1433         ld  hl,(your_prevpos+16);then, fire from multiple position
1434         cal fire_multiple
1435         ld  hl,(your_prevpos+30)
1436         cal fire_multiple
1437         ld  hl,(your_prevpos+44)
1438         cal fire_multiple
1439         ld  hl,(your_prevpos+58)
1440         cal fire_multiple       ;no JP: that messes up the stack
1441         ret
1442
1443 Fire_bullet:
1444         ld  hl,just_fired       ;=for how long you may hold fire (2nd)
1445         ld  a,(hl)              ;a = time left
1446         dec a                   ;decrease timer
1447         ret z                   ;may not fire when (just_fired) became 0
1448         ld  (hl),a              ;save new decreased value
1449
1450         ld  a,(your_weapon)     ;if you have bullets.....
1451         cp  maxweapon
1452         jr  nc,fireOK           ;>weapons = laser
1453         ld  (hl),1              ;bullet may last one turn (just fire 1 bullet)
1454 fireOK:
1455         ld  a,(your_weapon)     ;weapon nr.
1456         ld  ix,weapondata+2
1457         add a,a                 ;weap*2
1458         add a,a                 ;    *4
1459         add a,a                 ;    *8
1460         ld  c,a
1461         ld  b,0                 ;go to current weapon (bc=a)
1462         add ix,bc               ;ix=weapon ptr
1463
1464         ld  a,(your_multiples)  ;any multiples?
1465         and %1111               ;nr. of multiples
1466         cal nz,fire_multiples   ;if >0 then fire them too
1467         ld  hl,(x)              ;fire from ship position (x)
1468 fireany:                        ;HL=(x,y)
1469         ld  (firex),hl          ;set position to fire from
1470         ld  b,3  ;or use the proc at fireOK with ld ix,weapondata+2-(256*3)
1471 fire_weapon:
1472         psh bc                  ;save counter
1473         ld  a,(ix)              ;load this weapon
1474         ld  c,a                 ;save bulletType in c
1475         and %11100000           ;%111?????=laser
1476         cp  %11100000           ;is it?
1477         cal z,fire_laser        ;fire laser (will set c=0 when done)
1478         xor a                   ;<>0=bullet
1479         cp  c                   ;c<>0?
1480         cal nz,fire_ybullet     ;then fire bullet
1481         inc ix                  ;otherwise fire next weapon
1482         inc ix
1483         pop bc                  ;weapon counter (do 3 weapons)
1484         dnz fire_weapon
1485
1486 fire_tail:
1487         ld  ix,extrabulletpos-1 ;extra bullet's position
1488         ld  hl,your_extra       ;data
1489         ld  a,(hl)
1490         or  a
1491         ret z
1492 ;       ld  c,tailbeam          ;tailbeam weapon data
1493 ;       dec a                   ;(your_extra)=1
1494 ;       jr  z,fire_ybullet      ;=tail
1495         ld  c,doublebeam        ;up double data
1496                                 ;(your_extra)=2 =double
1497 ;-----fire BULLETs-----
1498
1499 fire_ybullet:           ;fire bullet type=C dam=(curweapdamage) at (firex/y)
1500         ld  hl,ybullets         ;check for unused bullet
1501         ld  de,4
1502         ld  b,nrybuls
1503 find_ybullet:
1504         ld  a,(hl)
1505         or  a
1506         jr  z,found_ybullet     ;0 = no bullet here
1507         add hl,de
1508         dnz find_ybullet        ;look next bullet
1509         ret                     ;none found, return don't fire
1510
1511 found_ybullet:
1512         ld  (hl),c              ;use the bullet and set correct bullet-type
1513         inc hl                  ;@damage
1514         ld  (hl),1              ;set bullet damage
1515 curweapdamage =$-1
1516         ld  a,(firex)           ;your x-pos
1517         add a,5                 ;place bullet in front of you
1518         inc hl                  ;go to bullet-x
1519         ld  (hl),a              ;set x
1520
1521         ld  a,(firey)           ;your y-pos
1522         add a,(ix+1)            ;place bullet at the middle of your ship
1523         inc hl                  ;go to bullet-y
1524         ld  (hl),a              ;set y
1525
1526         xor a
1527         ld  (weapincs),a        ;reset damage
1528         ret
1529
1530 ;-----fire LASER-----
1531
1532 fire_laser:
1533         ld  b,0                 ;overflow counter
1534         ld  hl,firex
1535         ld  d,(hl)              ;d = your x-pos
1536         inc hl
1537
1538         ld  a,(hl)              ;base y-coord (firey)
1539         add a,(ix+1)            ;at specified offset (most likely the middle)
1540         ld  e,a                 ;save laser-y in e
1541         psh de                  ;save unmodified (x,y)
1542         add a,a                 ;y*2
1543 #ifdef TI86
1544         add a,a                 ;y*4 (86)
1545 #else
1546         add a,e                 ;y*3 (83)
1547 #endif
1548         add a,a                 ;y*8 (86) | y*6 (83)
1549         rl  b                   ;b (=0) =b*2+overflow (if y>32 then bc=bc+256)
1550         add a,a                 ;width of screen (y*16 (86) | y*12 (83))
1551         rl  b                   ;b=b*2+overflow (if y>64 then bc=bc+512)
1552         inc a                   ;8 pixels to right (a=even so no overflow)
1553
1554         srl d                   ;X/2
1555         srl d                   ;X/4
1556         srl d                   ;X/8
1557         add a,d                 ;a = (Y*16+X/8) mod 256 (c set on overflow)
1558
1559         jr  nc,_nolc            ;jump if no carry = no overflow = a<=255
1560         inc b                   ;a>255 so increase bc by 256
1561 _nolc:  ld  c,a                 ;c = (Y*16+X/8) mod 256
1562         ld  hl,dispbuffer       ;save-location
1563         add hl,bc               ;bc = Y*16+X/8: hl=screen address
1564         ld  a,scrwidth-1        ;128/8=16=screen width ** minus one (inc a ^^)
1565         sub d                   ;minus x-start (d=X/8)
1566         jr  z,handle_laser      ;if size=0=256x (right edge) then skip display
1567         ld  b,a
1568 drawlaser:
1569         ld  (hl),%11111111
1570         inc hl                  ;Go to next byte
1571         dnz drawlaser
1572 handle_laser:
1573         pop de                  ;de=(firex): x-pos unmodified
1574
1575 check_laserhits:                ;de = (x,y)
1576         psh ix
1577         ld  b,nrenemies         ;check all enemies
1578         ld  hl,enemies+1        ;enemy#1+occ/hp00
1579 laserhits:                      ;hits with normal enemies
1580         psh hl
1581         ld  a,(hl)              ;occ+hp00
1582         and %11                 ;normal enemy occ = %11
1583         cp  %11
1584         jr  nz,nolashit         ;no hit when enemy_occ <> 11
1585
1586         inc hl                  ;@type
1587         cal find_sprite         ;ix=sprite to enemy (hl)
1588         inc hl                  ;@x
1589         ld  a,(hl)              ;check x
1590         sub d
1591         jr  c,nolashit          ;no hit when enemy is left of you
1592         inc hl                  ;@y
1593         ld  a,(hl)              ;check y
1594         sub e
1595         jr  z,enemy_lashit      ;a-e=0 = laser on top line of enemy = hit
1596         jr  nc,nolashit         ;a-e>0 = enemy above laser = no hit
1597         dec a                   ;minus one
1598         add a,(ix+1)            ;add enemy height (according to sprite @ix)
1599         jp  m,nolashit          ;a-e>0 = hit
1600 enemy_lashit:
1601         psh hl                  ;pointer to enemy destroyed by putsprite
1602         psh bc                  ;safe enemy counter
1603         psh de                  ; and Ur position (used for further compares)
1604         dec e                   ;adjust y-position
1605         dec e
1606         dec e                   ;hit sprite centered at e (height=6)
1607         dec hl                  ;@x
1608         ld  d,(hl)              ;x-position of hit (enemy's x-pos)
1609         ld  ix,spr_lashit       ;laserHit sprite
1610         cal putsprite           ;display this frame only unlike bullethit ani
1611         pop de                  ;restore regs
1612         pop bc
1613         pop hl
1614         ld  a,(curweapdamage)   ;damage
1615         cal enemy_hit           ;inflict (hl=enemy+y)
1616 nolashit:
1617         pop hl                  ;enemy+1
1618         ld  a,b                 ;psh bc
1619         ld  bc,enemysize
1620         add hl,bc               ;go to next enemy
1621         ld  b,a                 ;pop bc
1622         dnz laserhits           ;check all enemies
1623         xor a
1624         ld  (weapincs),a        ;reset damage
1625         pop ix
1626         ld  c,a                 ;c=0
1627         ret
1628
1629 ;------------------------ handle bullets -------------------------------------
1630
1631 Handle_bullets:
1632         ld  hl,ybullets
1633         ld  b,nrybuls
1634 scan_bullets:
1635         ld  a,(hl)              ;@bulletType
1636         or  a                   ;bulletType=0 >> no bullet
1637         jp  z,next_ybullet+2    ;skip pops (+2); jP for speed
1638
1639         psh bc                  ;bullet counter
1640         psh hl                  ;save enemy+type
1641         ld  (temp1),hl          ;needed for check_bullethits
1642         inc hl                  ;@damage
1643         ld  c,(hl)              ;damage
1644         dec c                   ;c=damage-1
1645         jp  m,bullethitbullet   ;damage<=0 (=no bullet)
1646         inc hl                  ;@x
1647
1648 ;move_bullet
1649         ld  c,a                 ;c=type
1650         and %11111              ;pixels to move
1651         add a,(hl)              ;a = X + (hl) to the right
1652         sub 16                  ;and 16 to the left (so -16..+15)
1653         jr  c,remove_bullet     ;remove if x<0
1654         cp  8*scrwidth
1655         jr  nc,remove_bullet    ;or x>=128
1656         ld  (hl),a              ;save new pos.
1657         ld  d,a                 ;d = X
1658
1659         inc hl                  ;@y-pos
1660         ld  a,c
1661 #ifdef TI86
1662         rcl _shracc             ;%11100000->1110
1663 ;Note: a _shracc procedure inside Nemesis itself would be 27 cycles faster
1664 #else
1665         srl a \ srl a \ srl a \ srl a   ;83 doesn't have a shracc call
1666 #endif
1667         srl a                   ;%1110->111
1668         dec a
1669         jr  z,bullet_noymove    ;1=straight forward
1670         dec a
1671         jr  z,bullet_up         ;2=up
1672         dec a
1673         jr  z,bullet_halfup     ;3=1/2up
1674         dec a
1675         jr  z,bullet_down       ;4=down
1676 bullet_halfdown:                ;5=1/2down
1677         ld  a,(timer)
1678         rra                     ;carry once every other turn
1679         jr  c,bullet_noymove
1680 bullet_down:
1681         ld  a,(hl)
1682         inc a
1683         cp  55
1684         jr  z,bullet_noymove
1685         ld  (hl),a
1686 bullet_halfup:
1687         ld  a,(timer)
1688         rra                     ;CF every other turn
1689         jr  c,bullet_noymove
1690 bullet_up:
1691         ld  a,(hl)
1692         dec a
1693         jr  z,bullet_noymove
1694         ld  (hl),a
1695 bullet_noymove:
1696         ld  e,(hl)              ;e = Y
1697
1698 display_bullet:
1699         dec hl                  ;@x
1700         dec hl                  ;@damage
1701         ld  a,(hl)              ;bullet damage=size
1702         ld  hl,bullettable      ;pointer to first bullet
1703         srl a
1704         srl a                   ;per 4
1705         ld  b,0
1706         ld  c,a                 ;->16bit (de=a)
1707         add hl,bc               ;point to correct bullet offset
1708         ld  a,(hl)              ;load bullet offset
1709         ld  c,a                 ;convert to 16bit (d=0)
1710         ld  ix,spr_bullet01     ;first sprite
1711         add ix,bc               ;add offset (go to correct sprite)
1712
1713         ld  a,(ix)              ;bullet x-size
1714         ld  (bulletxsize),a     ;used at check_bullethits
1715         ld  a,(ix+1)            ;bullet y-size...
1716         ld  (bulletysize),a     ;...too
1717
1718         cal safeputsprite       ;display bullet; DE used for check_bullethits
1719
1720         cal check_bullethits
1721
1722 next_ybullet:
1723         pop hl                  ;restore enemy+type
1724         pop bc                  ;b=counter
1725         ld  de,4
1726         add hl,de
1727         dnz scan_bullets        ;next bullet (loop)
1728         ret
1729
1730 remove_bullet:
1731         pop hl                  ;enemy+type
1732         ld  (hl),0              ;dump this bullet!
1733         jr  next_ybullet+1      ;+1:skip pop hl at next_ybullet
1734
1735 bullethitbullet:                ;"bullet" just displaying a bullet hit
1736         inc c                   ;restore damage (to -5..0)
1737         jp  z,remove_bullet     ;if it's 0 remove it
1738         inc c                   ;increase to next frame
1739         ld  (hl),c              ;save new
1740         ld  a,c
1741         neg                     ;make positive value (frame nr. 0..4)
1742         add a,a                 ;*2
1743         ld  e,a
1744         add a,a                 ;*4
1745         add a,e                 ;*6
1746         ld  e,a
1747         ld  d,0                 ;de=a
1748         ld  ix,spr_hit          ;first hit sprite
1749         add ix,de               ;add frame nr*8 (goto correct sprite)
1750         inc hl                  ;@x
1751         ld  d,(hl)
1752         inc hl                  ;@y
1753         ld  e,(hl)              ;load position into de
1754         cal putsprite           ;display hit-sprite
1755         jr  next_ybullet        ;handle the other bullets
1756
1757 ;--------------------------- check bullethits --------------------------------
1758
1759 check_bullethits:               ;INPUT: de=X,Y; (temp1)=bullet
1760         ld  b,nrenemies
1761         ld  hl,enemies+1
1762
1763 hit_enemies:                    ;Hits with normal enemies
1764         psh bc                  ;enemy counter
1765         psh hl
1766
1767         ld  a,(hl)
1768         and %11
1769         cp  %11
1770         jr  nz,nohit            ;no hit when enemy_occ <> %11
1771
1772         inc hl                  ;enemy type
1773         cal find_sprite         ;set ix to the sprite of this enemy
1774
1775         inc hl                  ;@x
1776         ld  a,(hl)              ;check x
1777         sub d                   ;minus bullet x-position
1778         ld  b,a                 ;psh a
1779         sub 5                   ;minus bullet x-size
1780 bulletxsize =$-1
1781         jp  p,nohit             ;miss
1782         ld  a,b                 ;pop a
1783         add a,(ix)              ;add enemy width
1784         jp  m,nohit             ;miss
1785
1786         inc hl                  ;@y
1787         ld  a,(hl)              ;check y
1788         sub e                   ;minus bullet y-position
1789         ld  b,a                 ;psh a
1790         sub 3                   ;substract bullet height
1791 bulletysize =$-1
1792         jp  p,nohit             ;nope, missed it
1793         ld  a,b                 ;pop a
1794         add a,(ix+1)            ;add enemy height
1795         dec a                   ;minus one
1796         jp  m,nohit             ;missed after all
1797
1798                                 ;---bullet hits enemy (auch-time!)---
1799         psh hl
1800         ld  hl,0                ;@bulletType
1801 temp1 =$-2
1802         inc hl                  ;@damage
1803         ld  a,(hl)              ;damage to inflict on enemy
1804         ld  (hl),-(hitsprites+1);make this bullet exploding (damage = -5)
1805         pop hl                  ;enemy+y
1806         cal enemy_hit
1807 nohit:
1808         pop hl
1809         ld  bc,enemysize
1810         add hl,bc
1811         pop bc
1812         dnz hit_enemies         ;check next enemy
1813         ret
1814
1815 enemy_hit:                      ;*in:a=damage;hl=enemy+y
1816         add a,a                 ;a=damage to inflict
1817         add a,a                 ;first 2 bits used for occ.
1818         ld  b,a
1819
1820         dec hl                  ;@x
1821         dec hl                  ;@sprite+1
1822         dec hl                  ;@sprite
1823         dec hl                  ;@hp00 (occ)
1824         ld  a,(hl)              ;load hp00
1825         sub b                   ;decrease HP (if <0xx then c is set)
1826         ld  (hl),a              ;save (no flag-changes)
1827         dec hl                  ;@hp64; no change in c
1828         ld  a,(hl)              ;load; no c-change
1829         sbc a,0                 ;if cf then decrease a
1830         ld  (hl),a              ;save back the new value
1831         ret nc                  ;if a>=0 then return, otherwise explode
1832
1833         inc hl                  ;goto occ again
1834         ld  (hl),%01            ;set to explode
1835
1836         ld  a,(pickuptimer)     ;counts enemies destroyed
1837         dec a                   ;enough destroyed for a pickup?
1838         psh af                  ;save flags and a=0
1839         jr  nz,pickupdone       ;otherwise just explode
1840         ld  a,pickupfreq        ;reset enemies counter
1841 pickupdone:
1842         ld  (pickuptimer),a     ;save new enemiescounter value
1843         inc hl                  ;@sprite (=explosionFrame)
1844         ld  (hl),0              ;explosionFrame 0 or enemy #0=pickup
1845         pop af
1846         cal z,place_enemy       ;place pickup (enemy#=0=a cuz ZF)
1847
1848         ld  hl,1                ;increase score by one
1849         jp  scoreInc            ;+ret
1850
1851 ;--------------------------- level events ------------------------------------
1852
1853 Level_event:
1854         ld  a,0                 ;time to next event
1855 nextevent =$-1
1856         dec a                   ;decrease counter
1857         ld  (nextevent),a       ;store new value
1858         ret nz                  ;hasn't reached zero yet: get outta here!
1859
1860         ld  bc,0                ;enemy frequency (lvl)
1861 eventtime =$-2
1862         cal Random
1863         ld  (nextevent),a       ;set time to next event
1864         ld  hl,eventleft
1865         dec (hl)                ;update enemy-counter
1866
1867         ld  a,(hl)              ;look at counter
1868         or  a                   ;has it reached 0?
1869         jp  z,Next_level        ;yes: level finished
1870         dec a                   ;has it reached 1?
1871         jr  z,standby_event     ;yes: wait until no enemies present/left
1872         dec a                   ;has it reached 2?
1873         jr  z,place_boss        ;yep: place the BigBossTM!
1874         dec a                   ;has it reached 3?
1875         jr  nz,place_ranenemy   ;nope: >3 = place an enemy
1876         inc hl                  ;nextevent located behind eventleft
1877         ld  (hl),193            ;3: set delay for next boss to appear
1878         ret                     ;don't place any more enemies
1879
1880 standby_event:
1881         ld  b,nrenemies
1882         ld  hl,enemies+1-enemysize
1883         ld  de,enemysize
1884         xor a
1885 chk_enemyleft:
1886         add hl,de               ;go to next enemy
1887         cp  (hl)                ;0 = no enemy present
1888         jr  nz,enemyleft        ;if enemy present (<>0) then quit checking
1889         dnz chk_enemyleft       ;loop for all enemies
1890         ld  hl,nextevent        ;time 'til next event
1891         ld  (hl),157            ;next time to check is in 157 turns/frames
1892         ld  a,(your_weapon)
1893         cp  maxweapon           ;you have bullets?
1894         jr  nc,placebigupgrade  ;if not just place the big upgrade
1895         ld  a,(level)
1896         rra                     ;if level&1=0 (even levels)
1897         ret nc                  ;then dont place a pickup (=50%)
1898 placebigupgrade
1899         ld  a,1                 ;no enemies left: place upgrade pickup
1900         jr  place_enemy         ;place enemy #1(=a) = big pickup
1901 enemyleft:
1902         ld  hl,eventleft
1903         inc (hl)
1904         ret
1905
1906
1907 place_ranenemy:
1908         ld  hl,1                ;increase score by 1
1909         cal scoreInc
1910         ld  bc,0                ;0..nrlvlenemies
1911 nrlvlenemies =$-1               ;=nr of enemies minus 1
1912         cal Random              ;random enemy b..b+c = 0..nrenemies-1
1913         ld  b,0
1914         ld  c,a                 ;bc=a
1915         ld  hl,lvlenemies
1916         add hl,bc               ;go to a random enemy
1917         ld  a,(hl)              ;load enemy nr of this mysterious random enemy
1918         jr  place_enemy
1919
1920 place_boss:
1921         ld  hl,(levelp)         ;the leveldata (including the boss)
1922         dec hl                  ;points to leveldata\boss\enemynr
1923         ld  a,(hl)              ;load enemy# of boss
1924
1925 place_enemy:                    ;places enemy #=a (out:achl=?;b=0;de=@enemy+11)
1926         psh af
1927         ld  hl,enemies+1-enemysize
1928         ld  bc,enemysize
1929         xor a                   ;a=0
1930 chk_noenemy:                    ;find an unused (no) enemy
1931         add hl,bc               ;check next enemy
1932         cp  (hl)                ;(hl) = 0 ??
1933         jr  nz,chk_noenemy      ;jump if enemy present (non-0)
1934         ex  de,hl               ;de=hl=usable enemy +1
1935         pop af                  ;enemy# to place
1936         cal findenemyspecs      ;hl = enemy #a specs
1937
1938         dec de                  ;goto hp64 (before occ)
1939         ldi                     ;set hp64
1940         ldi                     ;set hitpoints+occ of enemy class
1941         ld  c,(hl)
1942         ldi                     ;set sprite
1943         ld  b,(hl)              ;bc=@enemy_sprite
1944         inc bc                  ;@sprite-height
1945         ld  a,(bc)
1946         ld  b,a                 ;b = sprite-height
1947         ldi                     ;set sprite + 1
1948         ldi                     ;set x-position
1949
1950         ld  a,(hl)              ;load placeInfo
1951         inc hl
1952         inc a                   ;is it -1?
1953         jr  z,random_enemy      ;yes: create random value <51 in a
1954         inc a                   ;is it -2?
1955         jr  z,lure_enemy        ;yes: create a 100% luring enemy
1956         inc a                   ;is it -3?
1957         jr  z,lure_enemy        ;yes: pick one (50% lure)
1958         inc a                   ;is it -4?
1959         jr  z,ground_enemy      ;yes: place @ current ground position
1960                                 ;otherwise?
1961 yset_enemy:                     ;set 0+3..$FC+3 as y-position
1962         ld  (de),a
1963         jr  ypos_OK
1964 ground_enemy:
1965         ld  a,(groundpos+15)    ;ground height
1966         neg                     ;negative (high ground, low y-pos)
1967         add a,50                ;at the bottom
1968         ld  (de),a              ;is turret's position
1969         jr  ypos_OK
1970 halflure_enemy:
1971         ld  a,(timer)           ;look at frame-number
1972         rra                     ;make random if odd frame nr.
1973         rra                     ;...well make that frame/2
1974         jr  nc,random_enemy     ;1st possibility: random enemy
1975 lure_enemy:                     ;2nd possibility: luring enemy
1976         ld  a,(y)               ;place at same y-pos as YOUR ship
1977         jr  ypos_OK
1978 random_enemy:
1979         ld  a,64-8              ;=57=screen height (8 is scorebar)
1980         sub b                   ;minus sprite height=bottom
1981         ld  c,0                 ;range=0 to...
1982         ld  b,a                 ;...57-y
1983         cal Random              ;random value on screen
1984 ypos_OK:                        ;random value successfully created
1985         ld  (de),a              ;save y-position
1986         inc de                  ;@movecounter
1987         ldi                     ;set move-type
1988         ld  a,1                 ;movecounter = 1
1989         ld  (de),a              ;set
1990         inc de                  ;@firecounter
1991         ldi                     ;set time-to-1st-fire
1992         ldi                     ;set firefreq
1993         ldi                     ; "  firetype
1994         ret                     ;return
1995
1996 ;--------------------------- enemy fires -------------------------------------
1997
1998 Enemy_fires:                    ;de = x,y; c = type; ix = enemy_sprite
1999         ld  hl,ebullets         ;first bullet to check
2000         ld  b,nrebuls
2001         dec d
2002         dec d                   ;d = x of firing enemy minus 2
2003
2004         ld  a,(ix+1)            ;the height of the enemy firing this bullet
2005         srl a                   ;halved
2006         add a,e                 ;added to his y-position
2007         ld  e,a                 ;into e
2008         dec e                   ;minus one (bullet height)
2009
2010 enemy_fires_again:              ;same but hl = first bullet possibly free
2011         xor a
2012 find_ebullet:
2013         cp  (hl)
2014         jr  z,found_ebullet     ;0 = not used
2015         inc hl \ inc hl \ inc hl
2016         dnz find_ebullet        ;look next bullet
2017         ret
2018
2019 found_ebullet:
2020         ld  a,c
2021         sub 6
2022         jp  c,bulletok          ;type #0-5 = done (normal/diag)
2023         or  a
2024         jp  z,bulletaiming      ;type #6 = aiming = type#2..5
2025         dec a
2026         jr  z,bullettriple      ;type #7 = triple
2027         dec a
2028         jr  z,bulletdouble      ;type #8 = double
2029         dec a
2030         jr  z,bulletwide5       ;type #9 = wide 5x
2031         dec a
2032         jr  z,bulletdquad       ;type #10 = double-quad
2033         dec a
2034         jr  z,bulletran         ;type #11 = random
2035         dec a
2036         jr  z,firesenemies      ;type #12 = mine + Dquad
2037         dec a
2038         jr  z,basefiresenemies  ;type #13 = enemies + 10
2039         dec a
2040         jr  z,randomfire        ;type #14 = random @full height
2041         dec a
2042         jr  z,bulletwide3       ;type #15 = wide triple
2043         dec a
2044         jr  z,bulletfullfire    ;type #16 = straight 5x
2045
2046 randomfire:
2047         ld  c,0
2048         ld  b,62
2049         cal Random              ;a=0..62
2050         ld  e,a
2051         ld  (hl),1
2052         jp  _bulletok
2053
2054 basefiresenemies:               ;type #13 = base
2055         ld  bc,$3A00
2056         cal Random
2057         ld  e,a
2058         cal random14
2059         ld  c,a
2060         cal bulletok            ;find and fire bullet
2061
2062         ld  a,boss2enemy        ;otherwise place enemy #[boss2enemy]
2063         jp  place_enemy
2064
2065 firesenemies:                   ;type #12 = mine / Dquad
2066         ld  a,(timer)
2067         rra                     ;if odd turn (50% chance)
2068         jr  c,bulletdquad       ;then fire 6x
2069         ld  a,boss1enemy        ;otherwise place enemy #[boss1enemy]
2070         jp  place_enemy
2071
2072 bulletran:                      ;type #11 = fires bullets 1-5 at random
2073         cal random14
2074         ld  (hl),a              ;set type a=1..5
2075         jr  _bulletok
2076
2077 bulletdquad:                    ;type #10 = double-quad
2078         cal bulletwide5         ;fire type #1 to 5
2079 addedgebullets:
2080         inc hl
2081         ld  a,e
2082         sub 7
2083         ld  e,a                 ;offset 7 up
2084         ld  c,1                 ;type #1 = normal
2085         cal enemy_fires_again
2086         inc hl
2087         ld  a,e
2088         add a,14
2089         ld  e,a                 ;offset 14 down (7 total)
2090 _enemy_fires_again:
2091         jr  enemy_fires_again
2092
2093 bulletwide5:                    ;type #9 = wide 5x (fires 4 dirs + 1 straight)
2094         cal bullettriple        ;fire type #1, 4 and 5
2095         inc hl                  ;next bullet
2096         ld  c,2                 ;type #2 = down
2097         cal enemy_fires_again
2098         inc hl
2099         ld  c,3                 ;type #3 = up
2100         jr  _enemy_fires_again
2101
2102 bulletfullfire:                 ;type #16 = straight 5 bullets
2103         cal bullettriple        ;fire 3 bullets at center (offset -2,+0,+2)
2104         inc e \ inc e           ;restore base (Y)position
2105         jr  addedgebullets      ;fire 2 more bullets (at offsets -7 and +7)
2106
2107 bullettriple:                   ;type #7 = triple
2108         cal bulletdouble+1      ;fire double weapon (offset +0,+2)
2109         dec e \ dec e           ;two px back up
2110         dec e \ dec e           ;and another two up (offset -2)
2111         inc hl                  ;next bullet position
2112         ld  c,1                 ;type #1 = normal
2113         jr  _enemy_fires_again  ;find and fire another bullet
2114
2115 bulletdouble:                   ;type #8 = double
2116         dec e                   ;one up (1st bullet not centered:offset -1,+1)
2117         ld  c,1                 ;type #1 = straight
2118         cal bulletok            ;fire bullet
2119         inc hl                  ;next bullet position
2120         inc e
2121         inc e                   ;two px down
2122         jr  _enemy_fires_again  ;find and fire another bullet
2123
2124 bulletwide3:                    ;type #15 = spread (3 bullets)
2125         ld  (hl),1              ;type #1 = normal
2126         cal _bulletok           ;fire
2127         inc hl                  ;next bullet
2128         ld  c,4                 ;type #4 = down 50%
2129         cal enemy_fires_again
2130         inc hl
2131         ld  c,5                 ;type #5 = up 50%
2132         jr  _enemy_fires_again
2133
2134 bulletaiming:                   ;type #6 = aiming = type#2..5
2135         ld  a,(y)
2136         sub e                   ;a = yourY-bulY = pixels bullet is above you
2137         add a,10
2138         jp  p,bulletnotup       ;jump when 10 pixels below you or higher
2139         ld  (hl),5              ;go slightly down
2140         add a,10                ;10 to 20 pixels below you
2141         jp  p,_bulletok         ;yes: all done.
2142         ld  (hl),3              ;otherwise move down even more
2143         jr  _bulletok
2144 bulletnotup:
2145         ld  (hl),1              ;normal bullet...
2146         sub 20                  ;...when...
2147         jp  m,_bulletok         ;...10 pixels below you to 20 pixels above
2148         ld  (hl),4              ;bullet going slightly up...
2149         sub 10                  ;...when...
2150         jr  c,_bulletok         ;...20 to 30 pixels above you
2151         ld  c,2                 ;else (more than 30 pixels) move up more
2152
2153 bulletok:
2154         ld  (hl),c              ;set bullet direction
2155 _bulletok:
2156         inc hl
2157         ld  (hl),d              ;set x-pos
2158         inc hl
2159         ld  a,58-5              ;bottom
2160         cp  e                   ;bullet-y...
2161         jr  nc,bulletonscreen   ;<bottom (=on screen) is ok (skip next part)
2162         ld  e,a                 ;otherwise set y-pos to bottom of screen
2163 bulletonscreen:
2164         ld  (hl),e              ;set y-pos
2165         ret
2166
2167 ;----------------------------- enemy bullets ---------------------------------
2168
2169 Enemy_bullets:
2170         ld  hl,ebullets         ;hl=bullet pointer
2171         ld  b,nrebuls           ;number of bullets (or _possible_ bullets)
2172 handle_bullet:
2173         psh bc
2174         psh hl
2175         ld  a,(hl)              ;load bulletType in a
2176         or  a                   ;bullet present?
2177         cal nz,enemy_bullet     ;non-0: handle bullet
2178         pop hl                  ;enemy_bullet could've added one or two to hl
2179         pop bc                  ;bullet counter
2180         inc hl \ inc hl \ inc hl ;next bullet (3 bytes per bullet)
2181         dnz handle_bullet       ;loop for each and every bullet
2182         ret
2183
2184 enemy_bullet:
2185         inc hl                  ;@x
2186         ld  d,(hl)              ;check if it has reached the left side of scrn
2187         bit 7,d                 ;x<0?
2188         jr  nz,remove_ebullet   ;yes, remove bullet
2189         dec d                   ;move one pixel left
2190         dec d                   ;and another one (that makes 2)
2191         ld  (hl),d              ;save new x-coordinate in (HL) and D
2192         inc hl                  ;@y   (BTW: x >= -2)
2193         ld  e,(hl)              ;e=y
2194
2195         dec a
2196         jr  z,ebullet_common    ;type 1: normal bullet
2197         dec a
2198         jr  z,ebullet_down      ;type 2: moving down
2199         dec a
2200         jr  z,ebullet_up        ;type 3: moving up
2201
2202         ld  b,a                 ;save bulletType
2203         ld  a,(timer)           ;load timer
2204         rra                     ;half speed (CF set every other turn)
2205         jr  c,ebullet_common    ;if bit then normal bullet
2206
2207         dec b
2208         jr  z,ebullet_down      ;type 4: moving down 50%
2209                                 ;type 5: moving up 50%
2210 ebullet_up:
2211         dec e                   ;move up
2212         jp  m,ebullet_common    ;y<top; don't save new value (so y=0)
2213         ld  (hl),e
2214         jr  ebullet_common
2215 ebullet_down:
2216         inc e                   ;move down
2217         ld  a,e                 ;a=y too
2218         cp  58-4                ;y>=bottom?
2219         jr  nc,ebullet_common   ;then keep it there
2220         ld  (hl),e              ;otherwise save new y
2221
2222 ebullet_common:
2223         ld  ix,spr_bullete1     ;display enemy bullet
2224         psh hl
2225         cal putsprite
2226         pop hl                  ;we'll need it again
2227
2228 ebullet_hits:
2229         ld  a,(your_occ)
2230         or  a
2231         ret nz                  ;0 = you're normal
2232
2233         ld  a,(y)               ;check y collision
2234         sub (hl)
2235         add a,6
2236         ret m
2237         cp  9
2238         ret nc
2239
2240         dec hl                  ;check x
2241         ld  a,(x)
2242         sub (hl)
2243         add a,6
2244         ret m
2245         cp  9
2246         ret nc
2247
2248         ld  b,auch_bullet       ;set damage-amount
2249         psh hl
2250         cal damage_you          ;HIT!!
2251         pop hl                  ;save hl to remove the bullet
2252 remove_ebullet:
2253         dec hl                  ;points to bullettype again
2254         ld  (hl),0              ;bullet > unused
2255         ret
2256
2257 ;--------------------------- handle enemies ----------------------------------
2258
2259 Handle_enemies:
2260         ld  hl,enemies+1
2261         ld  b,nrenemies         ;handle all enemies
2262
2263 handle_enemy:
2264         psh bc
2265         psh hl
2266
2267         ld  a,(hl)
2268         and %11
2269         jr  z,next_enemy        ;occ "no enemy" 00
2270         dec a
2271         jr  z,exploding_enemy   ;occ "exploding" 01
2272
2273 normal_enemy:
2274         ld  c,a                 ;c = occ-1 = %10 (normal) or %01 (pickup)
2275         inc hl                  ;@sprite
2276         cal find_sprite
2277
2278         inc hl                  ;@x
2279         ld  d,(hl)              ;x
2280         inc hl                  ;@y
2281         ld  e,(hl)              ;y
2282
2283         inc hl                  ;@movetype
2284         cal moving_enemy
2285         dec hl
2286
2287         ld  a,e                 ;new y value
2288         cp  57
2289         jr  c,enemyonscreenY    ;=on screen
2290         cp  -20                 ;moved off at top
2291         ld  e,0                 ;reset to top
2292         jr  nc,enemyonscreenY
2293         ld  e,57                ;otherwise reset to bottom
2294 enemyonscreenY:
2295         ld  (hl),e              ;store new y
2296         dec hl                  ;@x
2297
2298         ld  a,d                 ;new x value
2299         cp  129                 ;x<=128
2300         jr  c,enemyonscreenX    ;=on screen
2301         cp  -7                  ;x<=-8
2302         jr  c,remove_enemy      ;=off screen
2303 enemyonscreenX:
2304         ld  (hl),d              ;store new x
2305         dec c                   ;is this a pickup? (c=%01 so ZF=1)
2306         jr  nz,check_enemyfire  ;no, a normal enemy; let em fire
2307         jr  firing_done         ;continue
2308
2309 check_enemyfire:
2310         ld  bc,4                ;4x inc hl
2311         add hl,bc               ;@firecount
2312         ld  a,(hl)              ;counter till next blast
2313         dec a                   ;decrease it
2314         ld  (hl),a              ;save new value
2315         jr  nz,firing_done      ;finished if not reached 0 yet
2316
2317         inc hl                  ;@firefreq
2318         ld  a,(hl)              ;=time 'til next blast
2319         inc hl                  ;@firetype
2320         ld  c,(hl)              ;in c
2321         dec hl
2322         dec hl                  ;@firecount again
2323         ld  (hl),a              ;reset counter for next blast
2324         psh de                  ;save registers for firing-use
2325         cal Enemy_fires         ;fires bullet
2326         pop de                  ;restore (destroyed by Enemy_fires)
2327 firing_done:
2328         cal putwidesprite       ;display sprite @ix
2329
2330 next_enemy:
2331         pop hl
2332         ld  bc,enemysize
2333         add hl,bc
2334         pop bc
2335         dnz handle_enemy
2336         ret
2337
2338 exploding_enemy:
2339         inc hl
2340         ld  a,(hl)
2341         cp  16
2342         jr  nz,keep_enemy       ;remove when at last frame
2343 remove_enemy:
2344         pop hl
2345         ld  (hl),$0000          ;bye bye enemy
2346         jr  next_enemy+1        ;continue AFTER pop hl (already done)
2347 keep_enemy:
2348         inc a
2349         ld  (hl),a              ;next frame
2350         dec a                   ;1-16 -> 0-15
2351         ld  ix,spr_explosion    ;base sprite
2352         inc hl                  ;@x
2353         cal explosion_stuff     ;display explosion
2354         jr  next_enemy
2355
2356 ;--------------------------- moving enemies ----------------------------------
2357
2358 moving_enemy:
2359         dec d                   ;move left once
2360         ld  a,(hl)              ;how does this enemy move?
2361         and a
2362         ret z                   ;0 = (1<)
2363         ld  b,a
2364         ld  a,(timer)
2365         dec b
2366         jp  z,movetype_updown   ;1 = (1<) up / down
2367         dec b
2368         jr  z,movetype_vslow    ;2 = (.25<)
2369         dec b
2370         jr  z,movetype_slow     ;3 = (.5 <)
2371         dec b
2372         jr  z,movetype_lslow    ;4 = (.75<)
2373         dec b
2374         jr  z,movetype_mfast    ;5 = (1.25<)
2375         dec b
2376         jr  z,movetype_fast     ;6 = (1.5<)
2377         dec b
2378         jr  z,movetype_vfast    ;7 = (2  <)
2379         dec b
2380         jr  z,movetype_xfast    ;8 = (3  <)
2381         dec b
2382         jr  z,movetype_slowlure ;9 = (1<) move y towards you 50%
2383
2384         inc d                   ;speed 0
2385         dec b
2386         jr  z,movetype_lure     ;10 = (0) move y towards you
2387         dec b
2388         jr  z,movetype_slowlure ;11 = (0) lure 1/2 speed
2389         dec b
2390         jr  z,movetype_fulllure ;12 = x+y towards you 1/2 speed
2391         dec b
2392         jr  z,movetype_right    ;13 = (.5>)
2393         dec b
2394         jr  z,movetype_fright   ;14 = (1>)
2395         dec b
2396         jr  z,movetype_right    ;15 = (0)
2397         dec b
2398         ret z                   ;16 =
2399
2400 movetype_lboss:
2401         ld  a,104
2402         cp  d
2403         jr  c,dothemovethingy
2404         inc d                   ;x<110: move right
2405 dothemovethingy:
2406         jr  movetype_updown     ;move up and down and up and down and...
2407
2408 movetype_right:
2409         rra
2410         ret c                   ;speed 0 50%
2411 movetype_fright:
2412         inc d                   ;move right one px
2413         ret
2414
2415 movetype_fulllure:
2416         rra
2417         ret c                   ;50% speed
2418         cal movetype_lure
2419         ld  a,(x)
2420         cp  d
2421         jr  c,movetype_vfast    ;moves left (again)
2422 lure_right:
2423         inc d                   ;move right
2424         ret
2425
2426 movetype_slowlure:
2427         rra                     ;half the time
2428         ret c
2429 movetype_lure:
2430         ld  a,110
2431         cp  d
2432         jr  nc,dothelurethingy
2433         dec d                   ;x>109: move left
2434 dothelurethingy:
2435         ld  a,(y)
2436         cp  e
2437         ret z                   ;don't move vertically if equal
2438         jr  c,lure_up           ;below you then move up
2439 lure_down:                      ;above then move down
2440         inc e
2441         ret
2442 lure_up:dec e
2443         ret
2444
2445 movetype_smart:
2446         inc hl                  ;@movecount
2447         ld  a,(hl)
2448         inc a
2449         and %1111
2450         ld  (hl),a
2451
2452         or  a                   ;reset carry flag
2453         dec hl                  ;reset hl to <y>
2454         and %11111100
2455         jr  z,movetype_fast
2456
2457 movetype_lslow:
2458         and %11
2459         ret nz
2460         inc d                   ;don't move 25% of the time
2461         ret
2462 movetype_slow:
2463         rra
2464         ret c
2465         inc d                   ;don't move 50%
2466         ret
2467 movetype_vslow:
2468         and %11
2469         ret z
2470         inc d                   ;don't move 75%
2471         ret
2472
2473 movetype_mfast:
2474         rra
2475         ret c                   ;50% chance (makes it 25% total)
2476 movetype_fast:
2477         rra
2478         ret c                   ;once every other turn
2479 movetype_vfast:
2480         dec d                   ;move left twice
2481         ret
2482 movetype_xfast:
2483         dec d                   ;woowoo, now that's fast!
2484         dec d                   ;move left trice!
2485         ret
2486
2487 movetype_updown:
2488         inc hl                  ;@movecount
2489         ld  a,(hl)
2490         dec a
2491         and 127                 ;range 0..127
2492         ld  (hl),a              ;store new movecounter
2493         dec hl                  ;reset hl to @movetype
2494         and %00100000           ;ZF changes once every 64 turns
2495         ld  a,e                 ;load current y-position
2496         jr  z,movedown
2497 moveup: dec a                   ;decrease y-pos (=move up)
2498         ret m                   ;don't move off the screen (y<0)
2499         dec e                   ;save new y-pos
2500         ret                     ;finish
2501 movedown:
2502         inc a                   ;increase y-pos
2503         cp  55                  ;compare with bottom
2504         ret nc                  ;return if it has passed that line (>40)
2505         inc e                   ;otherwise save new position
2506         ret                     ;and return
2507
2508 ;--------------------------- check collision ---------------------------------
2509
2510 Enemies_hit:
2511         ld  hl,(x)              ;e = X, d = Y
2512         ld  de,$0707            ;add 7 to both d and e
2513         add hl,de
2514         ex  de,hl               ;e = X+7, d = Y+7
2515
2516         ld  hl,enemies+1
2517         ld  b,nrenemies         ;check all 20 enemies
2518 check_collision:
2519         psh bc                  ;counter
2520         psh hl                  ;pointer
2521         ld  a,(hl)
2522         and %10                 ;enemy status (%11=normal; %10=pickup)
2523         jr  z,check_next        ;2 or 3 = ok, otherwise: next enemy
2524         inc hl                  ;@sprite
2525
2526 collide_enemy:                  ;&&& include in Handle_enemy proc
2527         cal find_sprite
2528
2529         inc hl                  ;@x
2530         ld  a,(hl)              ;check x match
2531         sub e                   ;enemy position minus yours minus 7
2532         jp  p,check_next
2533         add a,6
2534         add a,(ix)              ;enemy width
2535         jp  m,check_next
2536
2537         inc hl                  ;@y
2538         ld  a,(hl)              ;check y match
2539         sub d                   ;same as with x-check
2540         jr  nc,check_next       ;(=jp p)
2541         add a,6
2542         add a,(ix+1)            ;enemy height
2543         jp  m,check_next
2544         dec hl                  ;@x
2545         dec hl                  ;@sprite+1
2546         dec hl                  ;@sprite
2547         dec hl                  ;@occ
2548
2549 take_pickup:
2550         ld  a,(hl)              ;load enemy occ
2551         rra                     ;if occ = %10 (can't be %00) then pickup
2552         jr  c,collide           ;otherwise normal enemy so you collide
2553         ld  (hl),0              ;remove
2554         rra                     ;skip this bit (=%1)
2555         rra                     ;this bit specifies the pickup ID (big/small)
2556         jr  nc,armorpickup      ;%0 = pickup increases armor and shield
2557                                 ;%1 = pickup selects (next) upgrade
2558         ld  hl,your_pickup      ;your pickups
2559         ld  a,(hl)              ;current
2560         inc a                   ;go to next
2561         cp  4                   ;pickups >=4?
2562         jr  c,not_maxpickup
2563         psh hl                  ;too much pickups
2564         ld  hl,250
2565         cal scoreInc            ;increase score by 250
2566         pop hl
2567         ld  a,1                 ;and reset to pickup #1
2568 not_maxpickup:
2569         ld  (hl),a              ;save new
2570         psh de
2571         cal disp_icons          ;display altered pickupicons
2572         pop de                  ;ld de,$0707
2573         jr  check_next          ;all done, next..
2574
2575 armorpickup:
2576         cal inc_armor           ;increase armor (like at end of level)
2577         ld  a,30                ;activate shield for 30*4=120 frames
2578         ld  (your_shield),a
2579         cal disp_icons          ;display status bar (new armor value)
2580         jr  check_next
2581
2582 collide:
2583         ld  a,(hl)
2584         sub auch_ecollide
2585         ld  (hl),a
2586         jr  nc,enemydamaged     ;enemy still ok (HP>=0)
2587         ld  (hl),%01            ;set to explode
2588         inc hl
2589         ld  (hl),0              ;explosionFrame 0
2590 enemydamaged:                   ;damage to enemy delivered
2591         ld  b,auch_collide      ;your damage
2592         cal damage_you
2593
2594 check_next:
2595         pop hl                  ;current enemy base (unaltered)
2596         ld  bc,enemysize        ;bytes per enemy
2597         add hl,bc               ;pointer to next enemy
2598         pop bc                  ;restore counter
2599         dnz check_collision     ;loop for all enemies
2600         ret
2601
2602 ;--------------------------- story -------------------------------------------
2603
2604 dostory:
2605 #ifdef story
2606         cal storyPage           ;do some story
2607         ld  a,(hl)              ;load next byte in a
2608         inc a                   ;set z-flag if a = $ff
2609         jr  nz,dostory          ;otherwise loop
2610         inc hl
2611         inc hl                  ;set hl to beginning of the level
2612         ld  (levelp),hl         ;set the level-pointer
2613         ret                     ;and return
2614
2615 storyPage:
2616         psh hl                  ;hl will be destroyed by _clrLCD
2617         rcl _clrLCD             ;clear screen
2618         pop hl
2619         ld  a,(hl)
2620         ld  (curline),a         ;begin line for special effect
2621 storyLine:
2622         ld  d,(hl)              ;vertical position of text
2623         inc hl
2624         ld  e,(hl)              ;horizontal text-position
2625         ld  (_penCol),de        ;set position
2626         inc hl
2627         rcl _vputs              ;display text
2628
2629         ld  a,(hl)              ;load next byte
2630         inc hl
2631         or  a                   ;0 means more text
2632         jr  z,storyLine         ;loop if there is
2633
2634         psh af
2635         psh hl
2636         ld  hl,VIDEO_MEM        ;copy text
2637         ld  de,dispbuffer       ;to GRAPH_MEM
2638         ld  bc,1024             ;entire screen
2639         ldir
2640         rcl _clrLCD             ;clear VIDEO_MEM
2641         pop hl
2642         pop bc                  ;last byte (<>0) is lines to SFX
2643         psh hl
2644         cal DoSFX               ;do special effects
2645         cal getsomekeys         ;wait for a key
2646         pop hl
2647         ret
2648
2649 DoSFX:  psh bc                  ;in:(curline)=beginLine;b=nrOfLines
2650
2651         ld  a,0                 ;get line number
2652 curline =$-1
2653         inc a                   ;go to the next line
2654         ld  (curline),a         ;update
2655         ld  l,a
2656         ld  h,0                 ;hl=a
2657         add hl,hl
2658         add hl,hl
2659         add hl,hl
2660         add hl,hl               ;*16 (a pixels down=a*16)
2661         sub 64                  ;a=a-64
2662         neg                     ;a=64-a (lines from bottom)
2663
2664         ld  b,h                 ;save hl for later
2665         ld  c,l
2666         ld  de,VIDEO_MEM        ;where to put sfx
2667         add hl,de               ;go to ymin
2668         ex  de,hl               ;put into de again
2669         ld  hl,dispbuffer       ;source of original
2670         add hl,bc               ;hl->source
2671
2672 sfxlaserdisp:                   ;display this frame on screen
2673         ld  bc,16               ;one line (=16 bytes, you'd know by now)
2674         ldir                    ;display (copy actually)
2675         ld  bc,-16              ;go up one line (not on screen)
2676         add hl,bc               ;so the same line will be displayed
2677         dec a                   ;counter
2678         jr  nz,sfxlaserdisp     ;repeat until whole screen is displayed
2679
2680         ld  b,11                ;11x 1/200sec = ~20 frames/s
2681 sfxlaserdelay:
2682         halt                    ;delay
2683         dnz sfxlaserdelay       ;8x
2684
2685         pop bc                  ;counter
2686         dnz DoSFX
2687         ret
2688 #else
2689         rcl _clrWindow
2690         ld  hl,welldone
2691         rcl _puts
2692         jp  getsomekeys         ;wait for a key
2693 welldone:
2694         .db "-CONGRATULATIONS!-",0
2695 #endif
2696
2697 ;--------------------------- proc --------------------------------------------
2698
2699 random14:                       ;random 1..1+4
2700         ld  c,1
2701         ld  b,4
2702 ;       cal Random
2703 Random:                         ;a=c<random<b+c; destr:none
2704         psh hl
2705         ld  hl,rancount         ;amount to increase with (0-255)
2706 randomloop:
2707         inc (hl)                ;change for next time
2708         ld  a,r                 ;value $0-7F (can be _anything_ so watch out!)
2709         add a,0                 ;add to last random value
2710 ranseed =$-1                    ;SMC :P
2711         add a,(hl)              ;add the changing increase value
2712                         ;(this is because R can be anything;
2713                         ; ie always be even so freeze when a must be 1<=a<=1)
2714         ld  (ranseed),a         ;save for next time
2715         cp  b                   ;a>=b
2716         jr  nc,randomloop       ;then add again
2717         add a,c                 ;a<b; a=a+c
2718         pop hl
2719         ret
2720 rancount: .db 0
2721
2722 RandomY:                        ;HL = random Y 0..50 right side ((1..51)*16-1)
2723 #ifdef TI86
2724         psh bc
2725         ld  bc,50*256+1         ;range=1..51
2726         cal Random              ;a = 1..51
2727         add a,a
2728         add a,a
2729         ld  h,0
2730         ld  l,a                 ;hl = 1..51
2731         add hl,hl
2732         add hl,hl               ;hl = 1..51 * 16 (left side at random y)
2733         dec hl                  ;hl = 0..50 * 16 (" at right side of screen)
2734         ld  de,dispbuffer
2735         add hl,de               ;position on screen
2736         pop bc
2737         ret
2738 #else
2739         psh bc
2740         ld  bc,50*256+1         ;range=1..51
2741         cal Random              ;a = 1..51
2742         ld  d,a                 ;*1
2743         add a,a                 ;*2
2744         add a,d                 ;*3
2745         ld  h,0
2746         ld  l,a                 ;hl = 1..51 * 3
2747         add hl,hl
2748         add hl,hl               ;hl = 1..51 * 12 (left side at random y)
2749         dec hl                  ;hl = 0..50 * 12 (" at right side of screen)
2750         ld  de,dispbuffer
2751         add hl,de               ;position on screen
2752         pop bc
2753         ret
2754 #endif
2755
2756 scoreInc:                       ;increase score by HL
2757         psh bc                  ;don't destroy bc (or any registers Xcept hl)
2758         ld  bc,(your_score)     ;your current score in bc
2759         psh af                  ;don't destroy a either
2760         ld  a,(hardcore)        ;load hardcore mode settings in a
2761         or  a                   ;is it zero?
2762         jr  z,scoreincok        ;then skip the next instruction (score = ok)
2763         add hl,hl               ;otherwise (hardcore) double the inc.score
2764 scoreincok:
2765         pop af                  ;restore a register
2766         add hl,bc               ;add bc to hl (or vice versa)
2767         ld  (your_score),hl     ;save new increased score
2768         pop bc                  ;all registers to what they were
2769         ret
2770
2771 find_sprite:                    ;in:hl=enemy+type | out:ix=sprite to enemy
2772         ld  a,(hl)              ;sprite byte #1
2773         .db $DD,$6F ;ld hx,a
2774         inc hl                  ;@sprite+1
2775         ld  a,(hl)              ;sprite byte #2
2776         .db $DD,$67 ;ld lx,a    ;ld ix,(hl)
2777         ret
2778
2779 BLACKLCD:
2780         ld  hl,VIDEO_MEM        ;screen location (top left)
2781         ld  de,VIDEO_MEM+1
2782         ld  (hl),%11111111
2783         ld  bc,scrwidth*64-1    ;do it 1024 times = entire screen
2784         ldir
2785 #ifdef TI83
2786         cal fastCopy
2787 #endif
2788         set 3,(iy+5)            ;set white on black
2789         ret
2790
2791 getsomekeys:
2792         halt                    ;wait a li'l while and save batteries :P
2793         halt
2794         rcl GET_KEY             ;input keys
2795         or  a
2796         jr  z,getsomekeys       ;wait if none
2797         cp  K_SECOND            ;2nd pressed?
2798         ret z                   ;then return with zf set
2799         cp  K_ENTER             ;enter pressed
2800         ret                     ;then return with zf set, otherwise zf reset
2801
2802 releasekeys:
2803         halt
2804         ld  a,%10000000         ;all key-masks
2805         out (1),a
2806         in  a,(1)
2807         inc a                   ;cp %11111111 (no keys pressed)
2808         jr  nz,releasekeys      ;keep waitin
2809         jp  GET_KEY             ;clear buffer
2810
2811 findenemyspecs:                 ;enemy #a specs in (hl); in:b=0; out:ac=?
2812         ld  hl,enemyspecs       ;enemy "0" specs
2813         add a,a                 ;a=type*2
2814         ld  c,a                 ;b=0; bc=c=a=type*2
2815         add hl,bc               ;hl = enm#0 + type*2
2816         add a,a                 ;a=type*4 (max.type<64)
2817         ld  c,a                 ;bc=type*4
2818         add hl,bc               ;hl = enm#0 + type*6
2819         add hl,bc               ;hl = enm#0 + type*10
2820         ret                     ;hl = enemy specs
2821
2822 ;--------------------------- game over / new game / death --------------------
2823
2824 #ifdef shiscore
2825 chartable:                      ;use chartable-1 and add GET_KEY scancode
2826         .db ".<>!",0,0,0,0      ;down,L,R,up
2827         .db 0,"xtoje0",0        ;enter..clear
2828         .db " wsnid9",0         ;(-)..custom
2829         .db "zvrmhc8",0         ;dot..del
2830         .db "yuqlgb7#"          ;0..xvar
2831         .db $D9,"-pkfa6'"       ;on..alpha
2832         .db "54321",$D0,0,'*'   ;F5..F1,2nd,exit,more
2833
2834 save_lvl:
2835         ld  hl,storesave_end-storesave_start
2836         psh hl                  ;size
2837         ld  hl,storesave_start
2838         psh hl                  ;dest
2839         ld  hl,4+storesave_start-_asm_exec_ram
2840         psh hl                  ;src
2841         jr  storesmtn
2842
2843 save_hi:
2844         ld  hl,storehi_end-storehi_start
2845         psh hl                  ;size
2846         ld  hl,storehi_start
2847         psh hl                  ;destination
2848         ld  hl,4+storehi_start-_asm_exec_ram
2849         psh hl                  ;source
2850
2851 storesmtn:              ;stores data [stack=src; stack+1=dest; stack+2=size]
2852         ld  hl,_asapvar         ;find own variable
2853         rst 20h                 ;cal _ABS_MOV10TOOP1
2854         rst 10h                 ;cal _FINDSYM
2855
2856         xor a                   ;bde=pointer to begin of real program
2857         pop hl                  ;data offset
2858         add hl,de               ;hl=pointer to data in real prog
2859         adc a,b                 ;if hl overflow also increase a
2860         rcl _SET_ABS_DEST_ADDR  ;destination = real program = ahl
2861         xor a                   ;RAM page #0
2862         pop hl                  ;data position in normal program ($D748+)
2863         rcl _SET_ABS_SRC_ADDR   ;set as source (ahl)
2864         pop hl                  ;size
2865         rcl _SET_MM_NUM_BYTES   ;set
2866         rcl _mm_ldir            ;copy data to real program
2867         jp  _RAM_PAGE_1         ;and finally: reset ram page
2868 #endif
2869
2870 game_over:                      ;stack=+0
2871         cal BLACKLCD            ;clear screen
2872 #ifdef TI86
2873         ld  hl,$0603            ;centered on 86
2874 #else
2875         ld  hl,$0403            ;centered on 83 (smaller screen)
2876 #endif
2877         ld  (_curRow),hl        ;center
2878         ld  hl,txt_gameover
2879         rcl _puts               ;display "GAME OVER"
2880         cal releasekeys         ;wait for all keys to be released
2881
2882         ld  hl,$0007
2883         ld  (_curRow),hl
2884 #ifdef shiscore
2885         ld  de,(your_score)     ;current score
2886         ld  hl,(hiscore)        ;hiscore
2887         rcl CP_HL_DE            ;de<=hl means no hiscore (or same)
2888         jr  nc,no_hiscore       ;skip the new hiscore part
2889         ld  (hiscore),de        ;otherwise save current score as new hiscore
2890
2891 ask_hiname:                     ;and ask for new hiscore name
2892         ld  ix,hiname           ;where to store the hiscore name
2893         ld  a,9                 ;max. length <9
2894         ld  (hiscorepos),a      ;current char (counts backwards 9-1)
2895 enter_name_loop:
2896         ld  a,'_'               ;cursor appearance
2897         rcl _putmap             ;display (do not advance cursorpos)
2898 nokeypressed:
2899         cal getsomekeys         ;wait for any key
2900         jr  z,nomore            ;if [enter] or [2nd] pressed we're all done
2901
2902         ld  hl,hiscorepos       ;string position
2903         cp  K_DEL               ;[DEL] functions as "backspace"
2904         jr  z,backup            ;delete previous char if pressed
2905         cp  K_EXIT              ;exit also ends name
2906         jr  z,nomore
2907
2908         ld  b,(hl)              ;(hiscorepos)
2909         dec b                   ;next position (counts backwards)
2910         jr  z,nokeypressed      ;if it's 1 (became 0) then don't add no more
2911         ld  (hl),b              ;otherwise save new string position
2912
2913         ld  hl,chartable-1      ;chars to add for each key
2914         ld  e,a
2915         ld  d,0                 ;de = key pressed
2916         add hl,de               ;add so we know which char to add for this key
2917         ld  a,(hl)              ;load in a
2918         or  a                   ;if it's 0 then
2919         jr  z,nokeypressed       ;don't add anything afterall
2920
2921         ld  (ix),a              ;save new char
2922         rcl _putc               ;and also display on screen
2923         inc ix                  ;goto next char
2924         cal releasekeys         ;wait for the key to be released
2925         jr  enter_name_loop     ;and continue the loop
2926
2927 backup:                         ;backspace
2928         ld  a,(hl)              ;(hiscorepos)
2929         cp  9                   ;9 means begin (0 total chars)
2930         jr  nc,nokeypressed     ;nothing to remove so continue loop
2931         inc (hl)                ;otherwise pos one back
2932
2933         dec ix                  ;and string to previous char as well
2934         ld  a,32                ;remove cursor
2935         rcl _putmap             ;by replacing it by ' '
2936         ld  hl,_curCol
2937         dec (hl)                ;cursor one back
2938         jr  enter_name_loop     ;continue name loop
2939
2940 nomore:                         ;name's done
2941         ld  a,' '               ;remove cursor
2942         rcl _putc               ;(or actually replace with ' ')
2943         ld  (ix),0              ;end of string marker (zero-terminated)
2944         cal save_hi             ;store hiscore with name in real program
2945         jr  hiscoredone         ;continue with game over screen
2946 #endif
2947 no_hiscore:                     ;no new hiscore
2948         ld  hl,hiname           ;just display old name
2949         rcl _puts
2950
2951 hiscoredone:
2952         xor a                   ;clear a (Ahl will be displayed)
2953         ld  hl,$1006            ;bottom-1 right
2954         ld  (_curRow),hl        ;set
2955         ld  hl,(your_score)     ;your score
2956         rcl _dispahl            ;display it (a=0)
2957
2958 #ifdef TI86
2959         ld  hl,$314b            ;bottom-1 right before score ^^
2960 #else
2961         ld  hl,$312b
2962 #endif
2963         ld  (_penCol),hl        ;set
2964         ld  hl,txt_score        ;"Score"
2965         rcl _vputs              ;display (small)
2966
2967         ld  hl,$1007            ;bottom right
2968         ld  (_curRow),hl        ;set
2969         ld  hl,(hiscore)        ;hi-score
2970         rcl _dispahl            ;display
2971 #ifdef TI86
2972         ld  hl,$3946            ;bottom right before hiscore ^^
2973 #else
2974         ld  hl,$3926
2975 #endif
2976         ld  (_penCol),hl        ;set
2977         ld  hl,txt_hiscore      ;"Hiscore"
2978         rcl _vputs              ;display (small)
2979         res 3,(iy+5)
2980
2981         ld  b,scrwidth
2982         ld  de,scrwidth
2983         ld  hl,VIDEO_MEM+(49*scrwidth)-1
2984 restore_line:
2985         set 1,(hl)
2986         add hl,de
2987         dnz restore_line
2988
2989         cal getsomekeys         ;wait for keypress
2990         jp  quit                ;restore some things and return to TI-OS/shell
2991
2992 invship:                        ;procedure used in New_game
2993         psh af
2994         inc b
2995         ld  de,12*scrwidth
2996         ld  hl,scrwidth*(3-12)+VIDEO_MEM;begin pos
2997 invshipinit:
2998         add hl,de
2999         dnz invshipinit
3000         ld  b,12*scrwidth       ;12 lines down
3001 invshiploop:
3002         ld  a,(hl)
3003         cpl                     ;invert byte
3004         ld  (hl),a
3005         inc hl
3006         dnz invshiploop         ;loop
3007         pop af
3008         ret
3009
3010 New_game:                       ;start a new game (SP=+0)
3011         rcl _clrLCD
3012 #ifdef TI86
3013         ld  a,VIDEO_MEM/$400
3014         ld  (PutWhere),a        ;will be reset after displaying iconbar
3015 #endif
3016         ld  ix,spr_ship01       ;first ship: sprite
3017         ld  de,$0105            ;position
3018         ld  b,4                 ;number of ships to display
3019 dispshipsloop:
3020         psh bc                  ;counter
3021         psh de                  ;position
3022         ld  h,e
3023 #ifdef TI86
3024         ld  l,40                ;x=40
3025 #else
3026         ld  l,30
3027 #endif
3028         ld  (_penCol),hl        ;small cursor position
3029         psh ix                  ;ix destroyed by _vputmap
3030         ld  hl,txt_difhardcore  ;hardcore ships text
3031         ld  a,b                 ;ship displaying (4 to 1)
3032         dec a                   ;minus 1 (3..0)
3033         psh af
3034         and %10                 ;gives 1,1,0,0 (for ships 0,0,1,1)
3035         jr  z,dispdifficulty    ;0 indicates hardcore difficulty ship
3036         ld  hl,txt_difnormal    ;normal difficulty ships text
3037 dispdifficulty:
3038         rcl _vputs              ;display difficulty
3039 #ifdef TI86
3040         ld  a,95
3041 #else
3042         ld  a,70
3043 #endif
3044         ld  (_penCol),a         ;set x=95
3045         pop af                  ;ship nr (backwards 3..0)
3046         ld  hl,txt_shpbeam      ;updouble for ships 1
3047         and %1                  ;gives 0,1,0,1 (for ships 0,1,0,1)
3048         jr  nz,dispsbeam
3049         ld  hl,txt_shplaser     ;tailbeam for ships 0
3050 dispsbeam:
3051         rcl _vputs              ;display special beam type
3052         pop ix
3053         pop de
3054         psh de                  ;peek de
3055         cal putwidesprite       ;display ship
3056         pop de
3057
3058         ld  bc,spr_ship01i-spr_ship01+2
3059         add ix,bc               ;go to next ship
3060         ld  a,12                ;below the previous one
3061         add a,e
3062         ld  e,a
3063         pop bc
3064         dnz dispshipsloop       ;loop
3065
3066         ld  b,0                 ;menu pos.
3067 selectship:
3068         psh bc
3069         cal invship
3070 #ifdef TI83
3071         cal fastCopy
3072 #endif
3073         cal getsomekeys
3074         pop bc
3075         jr  z,startthenewgame   ;enter/2nd
3076         cp  K_EXIT
3077         jp  z,menuexit          ;go game over when exit was pressed
3078         psh bc
3079         cal invship             ;display selection bar on current ship
3080         pop bc
3081         cp  K_DOWN              ;down pressed?
3082         jr  nz,selnotdown
3083         inc b                   ;move selection down
3084 selnotdown:
3085         cp  K_UP                ;up pressed?
3086         jr  nz,selnotup
3087         dec b                   ;move selection up
3088 selnotup:
3089         ld  a,b                 ;new selection
3090         and %11                 ;must be 0..3
3091         ld  b,a                 ;in b again
3092         jr  selectship          ;loop
3093
3094 startthenewgame:
3095         ld  hl,spr_ship01-(spr_ship02-spr_ship01)
3096         ld  de,spr_ship02-spr_ship01
3097         psh bc                  ;save b (ship#)
3098         inc b                   ;your ship #0-3++
3099         ld  a,b                 ;ship #1-4
3100 searchyourship:
3101         add hl,de               ;next ship
3102         dnz searchyourship
3103         ld  (your_ship),hl
3104         and 1                   ;gives: 1,0,1,0 for the ships
3105         xor 1                   ;well, make it 0,1,0,1 :)
3106         jr  z,whichship         ;ships 0 have bullets
3107         ld  a,maxweapon         ;ships 1 have lasers (0,8,0,8)
3108 whichship:
3109         ld  (your_weapon),a     ;set bullet#1 or laser#1 depending on ship
3110         pop af                  ;ship# 0..3
3111         and %10                 ;ships give 0,0,1,1
3112         ld  (hardcore),a        ;hardcore mode set for ships 3 and 4
3113         xor a                   ;ld a,0
3114         ld  (your_score),a      ;reset score
3115         ld  (your_score+1),a    ;reset score (0)
3116         ld  (your_extra),a      ;no extra beam
3117         ld  (your_pickup),a     ;reset pickups
3118         ld  (your_multiples),a  ;no multiples
3119         inc a                   ;ld a,1
3120         ld  (level),a           ;reset level nr (#1)
3121         ld  hl,levelstart       ;set level pointer to level#1
3122         ld  (levelp),hl         ;reset level pointer
3123         ld  a,4
3124         ld  (your_lives),a      ;3 lives (4 will be decreased @ You_die)
3125         ld  (pickuptimer),a     ;next pickup after 4 enemies destroyed
3126
3127 You_die:                        ;stack must be +1
3128         ld  a,24
3129         ld  (your_armor),a      ;24 HPs/shields
3130         ld  a,(your_lives)      ;load lives left
3131         dec a                   ;decrease lives
3132         ld  (your_lives),a      ;if lives=0ffh GO
3133         inc a                   ;if -1 then zf set now
3134         jp  z,game_over         ;and game's over
3135         jr  samelevel
3136
3137 ;--------------------------- next level --------------------------------------
3138
3139 Next_level:                     ;stack must be +1
3140         pop hl
3141
3142         cal inc_armor           ;increase armor
3143
3144         ld  hl,(levelp)         ;level pointer
3145         ld  b,0                 ;advance one level
3146         ld  c,(hl)
3147         add hl,bc               ;passed the enemies
3148         ld  c,9
3149         add hl,bc               ;update to point to next level
3150         ld  (levelp),hl         ;save
3151
3152         ld  a,(level)           ;level number
3153         inc a                   ;next level #
3154         cp  endlevel+1          ;last level done?
3155         jr  c,gamenotdone       ;no: continue game
3156 gamedone:                       ;yes:
3157         cal dostory             ;display end (hl=(levelp))
3158         ld  hl,500
3159         cal scoreInc            ;game complete bonus: 500
3160         jp  game_over           ;game over (+hiscore)
3161 gamenotdone:
3162         ld  (level),a
3163
3164         add a,a
3165         add a,a
3166         ld  h,0                 ;increase score....
3167         ld  l,a                 ;by level number * 4
3168         ld  bc,20
3169         add hl,bc               ;plus 20
3170         cal scoreInc            ;update score
3171
3172 samelevel:
3173         ld  hl,invertmode
3174         ld  de,_invert          ;sets B<>W mode
3175         ldi                     ;ld (_invert),(invertmode)
3176         ld  de,your_shipspr     ;sets your ship's sprite
3177         ldi                     ;ld (your_shipspr),(your_ship)
3178         ldi                     ;and second byte (heh it's a word)
3179
3180         ld  a,80
3181         ld  (nextevent),a       ;time to first enemy appearance
3182
3183         ld  hl,(levelp)         ;level pointer
3184 #ifdef story
3185         dec hl                  ;byte before level (boss byte)
3186         xor a                   ;if it's zero it means here's a story
3187         cp  (hl)
3188         inc hl                  ;begin of level
3189         cal z,dostory           ;do the story and set (levelp) to real level
3190 #endif
3191
3192         ld  a,(hl)              ;number of (different) enemies in this level
3193         inc hl
3194         ld  c,a
3195         ld  (nrlvlenemies),a    ;set nr of enemies-1
3196         ld  b,0                 ;bc=c so we can use ldir
3197         ld  de,lvlenemies       ;table of enemies
3198         ldir                    ;load enemies to table
3199         ld  a,(hl)              ;load new appearance-time
3200         ld  (eventtime),a
3201         inc hl
3202         ld  a,(hl)
3203         ld  (eventtime+1),a     ;set
3204         inc hl
3205         ld  a,(hl)              ;load nr of enemies in this level
3206         ld  (eventleft),a       ;set nr of events left
3207         inc hl
3208         ld  de,level_info
3209         ld  c,4                 ;5xLDI:  loads (level_info) (spacespace)
3210         ldir                    ;              (stars1) (stars2)
3211         ld  a,1
3212         ld  b,16                ;fill (groundpos)
3213 fillground:
3214         ld  (de),a
3215         inc de
3216         dnz fillground
3217
3218         ld  ix,starx1
3219         ld  b,nrstars1
3220         cal placestars
3221         ld  ix,starx2
3222         ld  b,nrstars2
3223         cal placestars
3224
3225         xor a
3226         ld  (timer),a           ;reset time
3227         ld  hl,your_occ         ;hl = your_occ
3228         ld  (hl),a              ;reset your ship (not exploding)
3229         inc hl                  ;hl = your_shield
3230         ld  (hl),25             ;set 25*4=100 frames shielded
3231         ld  de,$1820
3232         ld  (x),de              ;begin position (x,y)
3233         cal Place_multiples     ;place all multiple-positions at that (0,24)
3234
3235         cal loadweapon          ;load (your_weapon)
3236
3237         xor a
3238         ld  hl,enemies          ;remove all enemies and bullets
3239         ld  (hl),a              ;clear first byte
3240         ld  de,enemies+1        ;copy this to the next byte
3241 #ifdef TI86                     ;on '86 everything's located here
3242         ld  bc,(nrenemies*enemysize)+(nrybuls*4)+(nrebuls*3)-1
3243 #else                           ;on '83 it's a little harder...
3244         ld  bc,(nrenemies*enemysize)-1
3245         ldir                    ;just clear the enemies
3246         ld  hl,ybullets         ;now remove all the bullets (different loc.)
3247         ld  (hl),a              ;clear 1st byte
3248         ld  de,ybullets+1       ;copy2next
3249         ld  bc,(nrybuls*4)+(nrebuls*3)-1
3250 #endif
3251         ldir                    ;clear enemies + ybullets + ebullets
3252
3253 ;--------------------------- setup game --------------------------------------
3254
3255 game_setup:
3256         cal BLACKLCD            ;white on black
3257         ld  hl,txt_level
3258         ld  de,$0703
3259         ld  (_curRow),de        ;center
3260         rcl _puts               ;display "LEVEL "
3261
3262         ld  a,(level)           ;current level
3263         ld  l,a
3264         ld  h,0                 ;in hl
3265         rcl UNPACK_HL           ;create first digit
3266         add a,'0'               ;0-9
3267         ld  b,a                 ;into b
3268         rcl UNPACK_HL           ;second digit
3269         add a,'0'               ;0-9
3270         rcl _putc               ;display second digit
3271         ld  a,b
3272         rcl _putmap             ;display first digit
3273
3274         ld  hl,txt_lives        ;bar text: "Lx0"...
3275         ld  de,$0904
3276         ld  (_curRow),de        ;display lives left below level nr
3277         rcl _puts
3278         ld  a,(your_lives)      ;lives left
3279         add a,'0'               ;make value 0='0'
3280         rcl _putc
3281
3282         cal releasekeys         ;wait for user to release all keys
3283         ld  hl,txt_savekey      ;"Press [F1] to save"
3284         ld  de,$3A46            ;bottom-right
3285         ld  (_penCol),de
3286         rcl _vputs
3287
3288         res 3,(iy+5)            ;set white on black
3289         cal getsomekeys         ;wait for keypress
3290 #ifdef shiscore
3291         cp  K_F1
3292         cal z,save_lvl
3293 #endif
3294
3295         rcl _clrLCD             ;clear screen
3296         cal disp_icons          ;display bottom icons +ret
3297         jp  game_main_loop
3298
3299 placestars:
3300         cal RandomY             ;a = random y-pos 1..bottom
3301         ld  a,b                 ;a =  b = star nr. = 1..7
3302         add a,a                 ;a = 2b = 2..14
3303         ld  d,0
3304         ld  e,a                 ;de = a = 2-14
3305         or  a
3306         sbc hl,de               ;substract from rand y => random pos anywhere
3307
3308         ld  (ix),l              ;save x-pos (l)
3309         ld  (ix+1),h            ;save y-pos (h)
3310         inc ix \ inc ix         ;next star
3311         dnz placestars          ;repeat for all stars
3312         ret
3313
3314 loadweapon:
3315         ld  a,(your_weapon)
3316         add a,a                 ;weap*2
3317         add a,a                 ;    *4
3318         add a,a                 ;    *8
3319         ld  c,a
3320         ld  b,0
3321         ld  hl,weapondata
3322         add hl,bc
3323         ld  a,(hl)
3324         ld  (weapdamage),a      ;damage of bullets
3325         inc hl
3326         ld  a,(hl)
3327         ld  (weapdaminc),a      ;damage increase
3328         inc hl
3329         ld  a,(hl)
3330         and %00011111           ;laser duration
3331         ld  (laserdur),a
3332         ret
3333
3334 ;--misc--
3335 #ifdef TI83
3336 _clrLCD:
3337         rcl _clrlcdf
3338         ld  hl,dispbuffer       ;move from (hl) = top left
3339         ld  (hl),0              ;first pixel will be copied all over the screen
3340         ld  de,dispbuffer+1     ;(de) = next pixel, thus clearing whole screen
3341         ld  bc,scrwidth*64-1    ;loop 896 times = (128/8) * (64-8 for scorebar)
3342         ldir                    ;all clear!
3343         ret
3344 #endif
3345
3346 ;-----------------------------------------------------------------------------
3347 ;--------------------------- putsprite ---------------------------------------
3348 ;-----------------------------------------------------------------------------
3349 ;in:  de=(x,y); ix=sprite
3350 ;out: ix=behind sprite; hl:a=right below sprite; b=0; d=width; ce=?
3351
3352 #ifdef TI86
3353 putsprite:
3354         ld  c,(ix)              ;save width
3355 _putsprite:                     ;putsprite with custom width
3356         ld  a,d                 ;a=X
3357         bit 7,d                 ;check sign bit of X
3358         jr  z,CSpositive        ;X>=0
3359
3360         neg                     ;a=|X|
3361         cp  (ix)                ;off screen?
3362         ret nc                  ;X<=-width: don't draw at all
3363         ld  b,a                 ;b=|X|mod 8=1..7=bits to draw
3364         ld  a,%11111111         ;all bits set (draw everything)
3365 CSclipleft:
3366         srl a                   ;remove first bit in a for each b
3367         dnz CSclipleft          ;b=1: a=%01111111
3368                                 ;b=2: a=%00111111
3369                                 ;b=3: a=%00011111
3370                                 ;b=4: a=%00001111
3371                                 ;b=5: a=%00000111
3372                                 ;b=6: a=%00000011
3373                                 ;b=7: a=%00000001
3374         res 7,d                 ;X+128 (right side of screen)
3375         dec e                   ;Y--
3376         jr  CSdisplay           ;done clipping
3377
3378 CSpositive:
3379         sub 129-8               ;minus (screen width - byte width)
3380         ld  b,a
3381         ld  a,%11111111         ;clipmask
3382         jr  c,CSdisplay         ;x+width<128 then entire sprite is on screen
3383         inc b                   ;b = number of pixels off screen
3384 CSclipright:
3385         add a,a                 ;remove last bit in a for each b
3386         dnz CSclipright         ;b=1: a=%11111110
3387                                 ;b=2: a=%11111100
3388                                 ;b=3: a=%11111000
3389                                 ;b=4: a=%11110000
3390                                 ;b=5: a=%11100000
3391                                 ;b=6: a=%11000000
3392                                 ;b=7: a=%10000000
3393                                 ;b>7: a=%00000000 = off screen
3394
3395 CSdisplay:                      ;display the sprite ix at (d,e) masked
3396         ld  (CSclipmask),a      ;set mask
3397         cal findpixel           ;convert de to screen location hl:a
3398         ld  (CSbitmask),a
3399
3400         ld  d,c                 ;width
3401         ld  b,(ix+1)            ;height
3402 CSyloop:
3403         psh bc                  ;save rows to go
3404         psh hl                  ;screen
3405         ld  b,d                 ;width
3406         ld  a,(ix+2)            ;load image line
3407         and 255                 ;mask
3408 CSclipmask =$-1
3409         ld  c,a                 ;c=image
3410         inc ix                  ;next
3411 CSbitmask =$+1
3412         ld  a,1                 ;saved bitmask
3413 CSxloop:
3414         sla c                   ;test leftmost pixel
3415         jr  nc,CSnodraw         ;don't draw if it's 0
3416         ld  e,a                 ;psh af: save bitmask
3417         or  (hl)
3418         ld  (hl),a              ;OR pixel with screen
3419         ld  a,e                 ;pop af
3420 CSnodraw:
3421         rrca                    ;next bit
3422         jr  nc,CSbitdrawn       ;carry set if bit "jumped"
3423         inc hl                  ;next byte
3424 CSbitdrawn:
3425         dnz CSxloop
3426         pop hl                  ;screen at x-offset=0
3427         ld  bc,16
3428         add hl,bc               ;next line
3429         pop bc                  ;rows counter
3430         dnz CSyloop
3431 CSdone: ret
3432 #endif
3433
3434 #ifdef TI83
3435 putsprite:
3436         ld  c,(ix)              ;save width
3437 _putsprite:                     ;putsprite with custom width
3438         ld  a,d                 ;a=X
3439         bit 7,d                 ;check sign bit of X
3440         jr  z,CSpositive        ;X>=0
3441
3442         neg                     ;a=|X|
3443         cp  (ix)                ;off screen?
3444         ret nc                  ;X<=-width: don't draw at all
3445         ld  b,a                 ;b=|X|mod 8=1..7=bits to draw
3446         psh bc
3447         ld  a,%11111111         ;all bits set (draw everything)
3448 CSclipleft:
3449         srl a                   ;remove first bit in a for each b
3450         dnz CSclipleft          ;b=1: a=%01111111
3451                                 ;b=2: a=%00111111
3452                                 ;b=3: a=%00011111
3453                                 ;b=4: a=%00001111
3454                                 ;b=5: a=%00000111
3455                                 ;b=6: a=%00000011
3456                                 ;b=7: a=%00000001
3457         pop bc
3458         psh af
3459         ld  a,96
3460         sub b
3461         ld  d,a
3462         pop af
3463         dec e                   ;Y--
3464         jr  CSdisplay           ;done clipping
3465
3466 CSpositive:
3467         sub 97-8                ;minus (screen width - byte width)
3468         ld  b,a
3469         ld  a,%11111111         ;clipmask
3470         jr  c,CSdisplay         ;x+width<128 then entire sprite is on screen
3471         inc b                   ;b = number of pixels off screen
3472 CSclipright:
3473         add a,a                 ;remove last bit in a for each b
3474         dnz CSclipright         ;b=1: a=%11111110
3475                                 ;b=2: a=%11111100
3476                                 ;b=3: a=%11111000
3477                                 ;b=4: a=%11110000
3478                                 ;b=5: a=%11100000
3479                                 ;b=6: a=%11000000
3480                                 ;b=7: a=%10000000
3481                                 ;b>7: a=%00000000 = off screen
3482
3483 CSdisplay:                      ;display the sprite ix at (d,e) masked
3484         ld  (CSclipmask),a      ;set mask
3485         cal findpixel           ;convert de to screen location hl:a
3486         ld  (CSbitmask),a
3487
3488         ld  d,c                 ;width
3489         ld  b,(ix+1)            ;height
3490 CSyloop:
3491         psh bc                  ;save rows to go
3492         psh hl                  ;screen
3493         ld  b,d                 ;width
3494         ld  a,(ix+2)            ;load image line
3495         and 255                 ;mask
3496 CSclipmask =$-1
3497         ld  c,a                 ;c=image
3498         inc ix                  ;next
3499 CSbitmask =$+1
3500         ld  a,1                 ;saved bitmask
3501 CSxloop:
3502         sla c                   ;test leftmost pixel
3503         jr  nc,CSnodraw         ;don't draw if it's 0
3504         ld  e,a                 ;psh af: save bitmask
3505         or  (hl)
3506         ld  (hl),a              ;OR pixel with screen
3507         ld  a,e                 ;pop af
3508 CSnodraw:
3509         rrca                    ;next bit
3510         jr  nc,CSbitdrawn       ;carry set if bit "jumped"
3511         inc hl                  ;next byte
3512 CSbitdrawn:
3513         dnz CSxloop
3514         pop hl                  ;screen at x-offset=0
3515         ld  bc,12
3516         add hl,bc               ;next line
3517         pop bc                  ;rows counter
3518         dnz CSyloop
3519 CSdone: ret
3520 #endif
3521
3522 ;--------------------------- putbigsprite -----------------------------------=
3523
3524 putwidesprite:
3525 ;destr: abcdehl+ix (ix=behind sprite; hl:a=right below sprite; b=0; d=width)
3526         ld  a,(ix)              ;width
3527         cp  9
3528         jr  c,putsprite         ;width<=8: just draw the sprite
3529
3530         ld  a,(ix)
3531         sub 8                   ;width>8
3532         psh af
3533         ld  c,8
3534         psh de
3535         cal _putsprite          ;otherwise draw one column (8 pixels wide)
3536         pop de
3537         inc ix                  ;no x-size to load
3538         ld  a,8                 ;next
3539         add a,d                 ;8 pixels right
3540         ld  d,a
3541         pop bc                  ;then draw the remaining pixels (c=width-8)
3542         ld  c,b
3543         jr  _putsprite
3544
3545 safeputsprite:                  ;cal putsprite with de intact
3546         psh de
3547         cal putsprite
3548         pop de
3549         ret
3550
3551 ;------------------------------- findpixel -----------------------------------
3552 ;based upon CLEM's fp | 131 cycles | 28 bytes | in:(d,e); out:hla; destr:de
3553
3554 #ifdef TI86
3555 findpixel:
3556         ld  a,e                 ;a=e=Y
3557         add a,a
3558         add a,a                 ;add a,a is 7 cycles faster than add hl,hl
3559         ld  h,dispbuffer/$400   ;switch to hl (Y<64) & set base to dispbuffer
3560 PutWhere =$-1                   ;screen base position/$400 (where x+y=0)
3561         ld  l,a                 ;hl=4*Y
3562         ld  a,d                 ;a=d=X
3563         rra                     ;RRA: carry flag must be reset!
3564         add hl,hl               ;that's what the adds are for :P
3565         rra
3566         add hl,hl               ;hl=16*Y
3567         rra                     ;a=X/8
3568         or  l
3569         ld  l,a                 ;hl=hl+a
3570         ld  a,d
3571         and 7                   ;a=X\8
3572         cpl
3573         rlca
3574         rlca
3575         rlca
3576         ld (FPbit),a
3577         xor a
3578 FPbit =$+1
3579         set 0,a
3580         ret
3581 #endif
3582
3583 #ifdef TI83
3584 findpixel:
3585         psh bc
3586         psh de
3587         ld  a,d
3588         cal ionGetPixel
3589         pop de
3590         pop bc
3591         ret
3592 #endif
3593
3594 ;-----------------------------------------------------------------------------
3595 ;------------------------------- sprites -------------------------------------
3596 ;-----------------------------------------------------------------------------
3597
3598 spr_ship01:             ;(normal; up double)
3599         .db 7,7         ;ship alpha class (vic viper)
3600         .db %11000000   ;██
3601         .db %11110000   ;████
3602         .db %01111110   ; ██████
3603         .db %11101000   ;███ █
3604         .db %01111110   ; ██████
3605         .db %11110000   ;████
3606         .db %11000000   ;██
3607 spr_ship01i:
3608         .db 8,7
3609         .db %11001010   ;██  █ █
3610         .db %11110101   ;████ █ █
3611         .db %01111110   ; ██████
3612         .db %11101001   ;███ █  █
3613         .db %01111110   ; ██████
3614         .db %11110101   ;████ █ █
3615         .db %11001010   ;██  █ █
3616
3617 spr_ship02:             ;(normal; tail beam)
3618         .db 7,7         ;ship gamma class
3619         .db %11111000   ;█████
3620         .db %01100000   ; ██
3621         .db %11111100   ;██████
3622         .db %11100110   ;███  ██
3623         .db %11111100   ;██████
3624         .db %01100000   ; ██
3625         .db %11111000   ;█████
3626 spr_ship02i:
3627         .db 8,7
3628         .db %11111010   ;█████ █
3629         .db %01100001   ; ██    █
3630         .db %11111101   ;██████ █
3631         .db %11100111   ;███  ███
3632         .db %11111101   ;██████ █
3633         .db %01100001   ; ██    █
3634         .db %11111010   ;█████ █
3635
3636 spr_ship03:             ;(hardcore; up double)
3637         .db 7,7         ;ship gamma class
3638         .db %11111000   ;█████
3639         .db %01100000   ; ██
3640         .db %11111100   ;██████
3641         .db %11100110   ;███  ██
3642         .db %11111100   ;██████
3643         .db %01100000   ; ██
3644         .db %11111000   ;█████
3645 spr_ship03i:
3646         .db 8,7
3647         .db %11111010   ;█████ █
3648         .db %01100001   ; ██    █
3649         .db %11111101   ;██████ █
3650         .db %11100111   ;███  ███
3651         .db %11111101   ;██████ █
3652         .db %01100001   ; ██    █
3653         .db %11111010   ;█████ █
3654
3655         .db 7,7         ;ship delta class (lord british)
3656         .db %11000000   ; ██
3657         .db %11110000   ; ████
3658         .db %11111100   ; ██████
3659         .db %01100010   ;  ██   █
3660         .db %11111100   ; ██████
3661         .db %11110000   ; ████
3662         .db %11000000   ; ██
3663 ;spr_ship03i:
3664         .db 8,7
3665         .db %11111100   ; ██████
3666         .db %11110010   ; ████  █
3667         .db %11111101   ; ██████ █
3668         .db %01100011   ;  ██   ██
3669         .db %11111101   ; ██████ █
3670         .db %11110010   ; ████  █
3671         .db %11111100   ; ██████
3672
3673 spr_ship04:             ;(hardcore; tail beam)
3674         .db 7,7         ;XC1701II ship
3675         .db %11110000   ;████
3676         .db %10001100   ;█   ██
3677         .db %11110010   ;████  █
3678         .db %01011110   ; █ ████
3679         .db %11110010   ;████  █
3680         .db %10001100   ;█   ██
3681         .db %11110000   ;████
3682 spr_ship04i:
3683         .db 7,7
3684         .db %11110000   ;████
3685         .db %10011100   ;█  ███
3686         .db %11111110   ;███████
3687         .db %01011110   ; █ ████
3688         .db %11111110   ;███████
3689         .db %10011100   ;█  ███
3690         .db %11110000   ;████
3691
3692 auch_bullet  = 1        ;damage to you when hit by an enemy bullet
3693 auch_ground  = 5        ;the same but when you hit the ground
3694 auch_collide = 4        ;when you hit an enemy
3695 auch_ecollide = 2*4     ;damage to the enemy that hit you (skip bit 0/1)
3696
3697 spr_multiple:
3698         .db 6,6         ;multiples
3699         .db %00000000   ;
3700         .db %00111000   ;  ███
3701         .db %01111100   ; █████
3702         .db %01111100   ; █████
3703         .db %01111100   ; █████
3704         .db %00111000   ;  ███
3705 spr_multiple2:
3706 spr_lashit:
3707         .db 7,7         ;multiples
3708         .db %00111000   ;  ███
3709         .db %01111100   ; █████
3710         .db %11111110   ;███████
3711         .db %11111110   ;███████
3712         .db %11111110   ;███████
3713         .db %01111100   ; █████
3714         .db %00111000   ;  ███
3715
3716 ;-------------------------------- explosions ---------------------------------
3717
3718 ;spr_lashit:            ;the same as spr_multiple2
3719 ;       .db 7,7
3720 ;       .db %00111000   ;     ███
3721 ;       .db %01111100   ;    █████
3722 ;       .db %11111110   ;   ███████
3723 ;       .db %11111110   ;▒▒▒███████
3724 ;       .db %11111110   ;   ███████
3725 ;       .db %01111100   ;    █████
3726 ;       .db %00111000   ;     ███
3727
3728 spr_hit:
3729 hitsprites = 5          ;btw: sprites stored backwards
3730         .db 5,4         ;5
3731         .db %10101000   ;█▒█ █
3732         .db %00001000   ;▒  ▒█
3733         .db %10000000   ;█ ▒ ▒
3734         .db %10101000   ;█▒█▒█
3735
3736         .db 5,4         ;4
3737         .db %01001000   ; █▒▒█
3738         .db %11010000   ;██ █▒
3739         .db %00101000   ;▒ █ █
3740         .db %11010000   ;██▒█
3741
3742         .db 5,4         ;3
3743         .db %00110000   ;  ██
3744         .db %10011000   ;█  ██
3745         .db %10001000   ;█ ▒▒█
3746         .db %00110000   ; ▒██
3747
3748         .db 5,4         ;2
3749         .db %00100000   ;▒ █▒
3750         .db %00001000   ; ▒▒ █
3751         .db %10110000   ;█▒██
3752         .db %01000000   ;▒█ ▒
3753
3754         .db 4,4         ;1
3755         .db %10010000   ;█  █
3756         .db %01100000   ; ██
3757         .db %01100000   ; ██
3758         .db %10010000   ;█  █
3759
3760 spr_explosion:
3761         .db 8,5         ;1
3762         .db %00000000
3763         .db %00011100   ;   ███
3764         .db %00111110   ;  █████
3765         .db %01010110   ; █ █ ██
3766         .db %00111000   ;  ███
3767         .db %00000000
3768
3769         .db 8,6         ;2
3770         .db %00110000   ;  ██
3771         .db %01001110   ; █ ▒███
3772         .db %10111110   ;█ █████
3773         .db %01001111   ; █ ▒████
3774         .db %00111000   ;  ███
3775         .db %00011010   ;   ██ █
3776
3777         .db 8,6         ;3
3778         .db %10110000   ;█ ██
3779         .db %01001110   ; █  ███
3780         .db %10110101   ;█ ██▒█▒█
3781         .db %01000101   ; █  ▒█▒█
3782         .db %00111110   ;  █████
3783         .db %01011010   ; █ ██ █
3784
3785         .db 8,6         ;4
3786         .db %00101010   ;▒ █▒█ █
3787         .db %01000110   ; █  ▒██
3788         .db %10110101   ;█ ██ █ █
3789         .db %01100110   ; ██  ██▒
3790         .db %00111100   ;  ████▒
3791         .db %01011001   ; █ ██ ▒█
3792
3793         .db 8,6         ;5
3794         .db %01000000   ; █▒ ▒ ▒
3795         .db %00100101   ; ▒█  █▒█
3796         .db %00010100   ;▒ ▒█ █ ▒
3797         .db %01000100   ; █▒  █
3798         .db %00010010   ;  ▒█▒▒█
3799         .db %10011010   ;█▒ ██ █▒
3800
3801         .db 8,6         ;6
3802         .db %01000100   ; █   █
3803         .db %00100000   ;  ▒█ ▒ ▒
3804         .db %00000001   ;   ▒ ▒ █
3805         .db %01000100   ; █   █
3806         .db %00100010   ;  █▒  █
3807         .db %01001000   ;▒█ ▒█ ▒
3808
3809         .db 8,6         ;7
3810         .db %00001000   ; ▒  █▒
3811         .db %11000010   ;██ ▒  █
3812         .db %00000000   ;       ▒
3813         .db %00100000   ; ▒█  ▒
3814         .db %00000001   ;  ▒   ▒█
3815         .db %00110000   ; ▒██▒
3816
3817         .db 8,6         ;8
3818         .db %00000100   ;    ▒█
3819         .db %00000000   ;▒▒    ▒
3820         .db %01000000   ; █
3821         .db %00000000   ;  ▒
3822         .db %00000010   ;      █▒
3823         .db %00100100   ;  █▒ █
3824
3825 spr_yexplosion:
3826         .db 8,5         ;1
3827         .db %00000000
3828         .db %00101100   ;  █ ██
3829         .db %00011110   ;   ████
3830         .db %00110100   ;  ██ █
3831         .db %00011000   ;   ██
3832         .db %00000000
3833
3834         .db 8,5         ;2
3835         .db %00000000
3836         .db %00010100   ;   █ █
3837         .db %00111010   ;  ███ █
3838         .db %01110110   ; ███ ██
3839         .db %00011000   ;   ██
3840         .db %00000000
3841
3842         .db 8,5         ;3
3843         .db %00000000
3844         .db %00101100   ;  █ ██
3845         .db %01100110   ; ██  ██
3846         .db %01001011   ; █  █ ██
3847         .db %00111100   ;  ████
3848         .db %00000000
3849
3850         .db 8,5         ;4
3851         .db %00111000   ;  ███
3852         .db %01011100   ; █ ███
3853         .db %10010111   ;█  █ ███
3854         .db %01000110   ; █   ██
3855         .db %00111000   ;  ███
3856         .db %00000000
3857
3858         .db 8,6         ;5
3859         .db %00111100   ;   ████
3860         .db %01001111   ; █  ████
3861         .db %10100011   ;█ █   ██
3862         .db %11000110   ;██   ██
3863         .db %01110101   ; ███ █ █
3864         .db %00111000   ;  ███
3865
3866         .db 8,6         ;6
3867         .db %00101110   ;  █ ███
3868         .db %10000011   ;█     ██
3869         .db %01000101   ; █   █ █
3870         .db %10100011   ;█ █   ██
3871         .db %01000110   ; █   ██
3872         .db %00110000   ;  ██
3873
3874         .db 8,6         ;7
3875         .db %00110110   ;  ██ ██
3876         .db %00000101   ;     █ █
3877         .db %10001001   ;█   █  █
3878         .db %01100001   ; ██    █
3879         .db %11000010   ;██    █
3880         .db %01010001   ; █ █   █
3881
3882         .db 8,6         ;8
3883         .db %00000110   ;     ██
3884         .db %00100001   ;  █    █
3885         .db %10000000   ;█
3886         .db %01000010   ; █    █
3887         .db %01000000   ; █
3888         .db %00010100   ;   █ █
3889
3890 ;--------------------------------- bullets -----------------------------------
3891
3892 bullettable:
3893         .db (spr_bullet01-spr_bullet01) ;0
3894         .db (spr_bullet02-spr_bullet01) ;4
3895         .db (spr_bullet03-spr_bullet01) ;8
3896         .db (spr_bullet04-spr_bullet01) ;12
3897         .db (spr_bullet05-spr_bullet01) ;16
3898         .db (spr_bullet06-spr_bullet01) ;20
3899         .db (spr_bullet07-spr_bullet01) ;24
3900         .db (spr_bullet08-spr_bullet01) ;28
3901         .db (spr_bullet09-spr_bullet01) ;32
3902         .db (spr_bullet10-spr_bullet01) ;36
3903         .db (spr_bullet11-spr_bullet01) ;40
3904         .db (spr_bullet12-spr_bullet01) ;44
3905         .db (spr_bullet13-spr_bullet01) ;48
3906
3907 spr_bullet01:
3908         .db 2,1
3909         .db %11000000   ;▒██
3910 spr_bullet02:
3911         .db 4,1
3912         .db %11110000   ;▒████
3913 spr_bullet03:
3914         .db 2,2
3915         .db %11000000   ;▒██
3916         .db %11000000   ;▒██
3917 spr_bullet04:
3918         .db 4,2
3919         .db %10110000   ;▒█▒██
3920         .db %10110000   ;▒█▒██
3921 spr_bullet05:
3922         .db 4,3
3923         .db %01100000   ; ▒██
3924         .db %11110000   ;▒████
3925         .db %01100000   ; ▒██
3926 spr_bullet06:
3927         .db 5,3
3928         .db %00110000   ;  ▒██
3929         .db %11111000   ;▒█████
3930         .db %00110000   ;  ▒██
3931 spr_bullet07:
3932         .db 5,3
3933         .db %01110000   ; ▒███
3934         .db %11111000   ;▒█████
3935         .db %01110000   ; ▒███
3936 spr_bullet08:
3937         .db 5,3
3938         .db %11110000   ;▒████
3939         .db %11111000   ;▒█████
3940         .db %11110000   ;▒████
3941 spr_bullet09:
3942         .db 5,4
3943         .db %00010000   ;   ▒█
3944         .db %10111000   ;▒█▒███
3945         .db %01111000   ; ▒████
3946         .db %00010000   ;   ▒█
3947 spr_bullet10:
3948         .db 6,4
3949         .db %00111000   ;  ▒███
3950         .db %01111100   ; ▒█████
3951         .db %11111100   ;▒██████
3952         .db %00110000   ;  ▒██
3953 spr_bullet11:
3954         .db 7,5
3955         .db %00011000   ;   ▒██
3956         .db %11111100   ;▒██████
3957         .db %00111110   ;  ▒█████
3958         .db %01111100   ; ▒█████
3959         .db %00011000   ;   ▒██
3960 spr_bullet12:
3961         .db 7,6
3962         .db %00110000   ;  ▒██
3963         .db %11111100   ;▒██████
3964         .db %00111110   ;  ▒█████
3965         .db %01111110   ; ▒██████
3966         .db %11111100   ;▒██████
3967         .db %00111000   ;  ▒███
3968 spr_bullet13:
3969         .db 8,8
3970         .db %00111100   ;  ▒████
3971         .db %11111110   ;▒███████
3972         .db %01111111   ; ▒███████
3973         .db %00011111   ;   ▒█████
3974         .db %01111111   ; ▒███████
3975         .db %11111110   ;▒███████
3976         .db %00111100   ;  ▒████
3977
3978 spr_bullett1:
3979         .db 4,3         ;▒▒▒
3980         .db %11100000   ;▒███
3981         .db %11110000   ; ████
3982         .db %01110000   ;  ███
3983
3984 spr_bullete1:
3985         .db 4,3         ;enemy bullets
3986         .db %01100000   ; ██▒
3987         .db %11110000   ;████▒
3988         .db %01100000   ; ██▒
3989
3990 ;format:[min.damage] [dam.inc] [000:direction 00000:speed] [offset]
3991 ;damage = min.damage + dam.inc*incs (0<=incs<=6)
3992 ;speed in pixels/frame (>=%10010=forward; <=%01110=backwards)
3993 ;direction: 001=straight forward; 010=up; 011=1/2up; 100=down; 101=1/2down
3994 ;           111=laser (speed=duration 00010-00000)
3995
3996 weapondata:     ;max = 9x6; 15x5; 21x4; 27x3
3997         .db 2,1,%00110010,3,%00000000,0,%00000000,0     ;1 single     (1x2+1)  2
3998         .db 3,1,%00110011,3,%00000000,0,%00000000,0     ;2 fast       (1x3+1)  3
3999         .db 2,1,%00110010,0,%00110010,6,%00000000,0     ;3 double     (2x2+1)  4
4000         .db 2,1,%01110010,2,%10010010,2,%00110010,2     ;4 triple     (3x2+1)  6
4001         .db 3,2,%00110011,2,%10010010,2,%01110010,2     ;5            (3x3+2)  9
4002         .db 4,2,%01110011,2,%10010011,2,%00110011,2     ;6            (3x4+2) 12
4003         .db 5,3,%01110100,2,%10010100,2,%00110100,2     ;7            (3x5+3) 15
4004         .db 7,4,%01110101,2,%10010101,2,%00110101,2     ;8            (3x7+4) 21
4005         .db 9,6,%01110110,2,%10010110,2,%00110110,2     ;9            (3x9+6) 27
4006 maxweapon  = 9
4007         .db 1,1,%11100100,3,%00000000,0,%00000000,0     ;1 single     (1x1x3)  3
4008         .db 2,3,%11100011,3,%00000000,0,%00000000,0     ;2 short      (2x1x2)  4
4009         .db 1,2,%11100100,3,%11100000,4,%00000000,0     ;3 fat        (1x2x3)  6
4010         .db 1,2,%11100101,0,%11100000,6,%00000000,0     ;4 double     (1x2x4)  8
4011         .db 4,4,%11100011,3,%00000000,0,%00000000,0     ;5 short      (4x1x2)  8
4012         .db 1,2,%11100100,3,%11100000,6,%11100000,0     ;6 triple     (1x3x3)  9
4013         .db 1,3,%11101000,3,%11100000,6,%11100000,0     ;7 triple long(1x3x7) 21
4014         .db 2,5,%11100101,2,%11100000,4,%00000000,0     ;8 double     (2x2x4) 32
4015         .db 1,9,%11101100,3,%11100000,2,%11100000,4     ;9 big fat lng(1x3xB) 33
4016 maxlaser   = 18
4017 tailbeam   = %00101101  ;180 degrees
4018 doublebeam = %01010010  ;45 degrees
4019 extrabulletpos:
4020         .db  3 ;tail/double yposition
4021
4022 ;------------------------------------ bar ------------------------------------
4023
4024 #ifdef TI86
4025
4026 spr_lship:
4027         .db 5,3                 ;li'l ship indicating lives left
4028         .db %11100000           ;███   ▒▒▒
4029         .db %01111000           ; ████  ▒▒▒▒
4030         .db %11100000           ;███   ▒▒▒
4031 lshipsize = 5                   ;space between two ship icons
4032
4033 spr_icon:
4034         .db 16,7        ;selected.......:.......:
4035         .db %11111111           ;████████████████
4036         .db %11000000           ;██             █
4037         .db %11000000           ;██             █
4038         .db %11000000           ;██             █
4039         .db %11000000           ;██             █
4040         .db %11000000           ;██             █
4041         .db %11111111           ;████████████████
4042         .db 7
4043         .db %11111111
4044         .db %00000001
4045         .db %00000001
4046         .db %00000001
4047         .db %00000001
4048         .db %00000001
4049         .db %11111111
4050 spr_icon00:
4051         .db 15,7        ;unused  .......:.......:
4052         .db %10000000           ;█
4053         .db %10111111           ;█ █████████████
4054         .db %10101010           ;█ █ █ █ █ █ █ █
4055         .db %10110101           ;█ ██ █ █ █ █ ██
4056         .db %10101010           ;█ █ █ █ █ █ █ █
4057         .db %10111111           ;█ █████████████
4058         .db %10000000           ;█
4059         .db 6
4060         .db %00000000
4061         .db %11111110
4062         .db %10101010
4063         .db %01010110
4064         .db %10101010
4065         .db %11111110
4066 ;spr_icon01:
4067 ;       .db 16,7        ;shield  .......:.......:
4068 ;       .db %10001111           ;█   ███████  █  ▒
4069 ;       .db %10011001           ;█  ██  █████  █ ▒
4070 ;       .db %10111100           ;█ ████   ████ █ ▒
4071 ;       .db %10111000           ;█ ███   █  ██ █ ▒
4072 ;       .db %10111100           ;█ ████   ████ █ ▒
4073 ;       .db %10011001           ;█  ██  █████  █ ▒
4074 ;       .db %10001111           ;█   ███████  █  ▒
4075 ;       .db 7
4076 ;       .db %11100100
4077 ;       .db %11110010
4078 ;       .db %01111010
4079 ;       .db %10011010
4080 ;       .db %01111010
4081 ;       .db %11110010
4082 ;       .db %11100100
4083 maxarmor = 63                           ;maximum HPs you can get
4084 ;spr_icon02a:
4085 ;       .db 16,6        ;tailbeam.......:.......:
4086 ;       .db %10000000           ;█               ▒
4087 ;       .db %10000011           ;█     ██        ▒
4088 ;       .db %10000001           ;█      ███      ▒
4089 ;       .db %10111011           ;█ ███ ███ ██  ██▒
4090 ;       .db %10000001           ;█      ███      ▒
4091 ;       .db %10000011           ;█     ██        ▒
4092 ;       .db %10000000           ;█               ▒
4093 ;       .db 5
4094 ;       .db %00000000
4095 ;       .db %00000000
4096 ;       .db %11000000
4097 ;       .db %10110011
4098 ;       .db %11000000
4099 spr_icon02:
4100         .db 16,7        ;updouble.......:.......:
4101         .db %10000000           ;█          ██   ▒
4102         .db %10000000           ;█         ██    ▒
4103         .db %10110000           ;█ ██     ██     ▒
4104         .db %10011100           ;█  ███          ▒
4105         .db %10111011           ;█ ███ ██   ████ ▒
4106         .db %10011100           ;█  ███          ▒
4107         .db %10110000           ;█ ██            ▒
4108         .db 5
4109         .db %00011000
4110         .db %00110000
4111         .db %01100000
4112         .db %00000000
4113         .db %00011110
4114 spr_icon03:
4115         .db 16,7        ;laser   .......:.......:
4116         .db %10000000           ;█               ▒
4117         .db %10001010           ;█   █ █     ▒▒▒ ▒
4118         .db %11101100           ;███ ██      ▒▒▒ ▒
4119         .db %11110111           ;████ ███████▒▒▒█▒
4120         .db %11101100           ;███ ██      ▒▒▒ ▒
4121         .db %10001010           ;█   █ █     ▒▒▒ ▒
4122         .db %10000000           ;█               ▒
4123         .db 4
4124         .db %00000000
4125         .db %00000000
4126         .db %00000000
4127         .db %11111111
4128 spr_icon04:
4129         .db 11,7        ;bullets .......:.......:
4130         .db %10000000           ;█       ██      ▒
4131         .db %10000011           ;█     █████ ▒▒▒ ▒
4132         .db %10011000           ;█  ██   ██  ▒▒▒ ▒
4133         .db %11111100           ;██████      ▒▒▒ ▒
4134         .db %10011000           ;█  ██   ██  ▒▒▒ ▒
4135         .db %10000011           ;█     █████ ▒▒▒ ▒
4136         .db %10000000           ;█       ██      ▒
4137         .db 7
4138         .db %11000000
4139         .db %11100000
4140         .db %11000000
4141         .db %00000000
4142         .db %11000000
4143         .db %11100000
4144         .db %11000000
4145 spr_icon05:
4146         .db 16,7        ;multiple.......:.......:
4147         .db %10000011           ;█     ███       ▒
4148         .db %10000001           ;█      ████  ██ ▒
4149         .db %10000001           ;█      ████     ▒
4150         .db %10000011           ;█     ███       ▒
4151         .db %10011000           ;█  ██           ▒
4152         .db %10111100           ;█ ████  ██    ██▒
4153         .db %10011000           ;█  ██           ▒
4154         .db 6
4155         .db %10000000
4156         .db %11100110
4157         .db %11100000
4158         .db %10000000
4159         .db %00000000
4160         .db %11000011
4161
4162 #endif
4163 #ifdef TI83
4164
4165 spr_lship:
4166         .db 3,3                 ;li'l ship indicating lives left
4167         .db %11000000           ;██  ▒▒
4168         .db %01100000           ; ██  ▒▒
4169         .db %11000000           ;██  ▒▒
4170 lshipsize = 3                   ;space between two ship icons
4171
4172 spr_icon:
4173         .db 10,7        ;selected.......:.......:
4174         .db %11111111           ;███████████
4175         .db %11000000           ;██        █
4176         .db %11000000           ;██        █
4177         .db %11000000           ;██        █
4178         .db %11000000           ;██        █
4179         .db %11000000           ;██        █
4180         .db %11111111           ;███████████
4181         .db 7
4182         .db %11100000
4183         .db %00100000
4184         .db %00100000
4185         .db %00100000
4186         .db %00100000
4187         .db %00100000
4188         .db %11100000
4189 spr_icon00:
4190         .db 9,7         ;unused  .......:.......:
4191         .db %10000000           ;█
4192         .db %10111111           ;█ ███████
4193         .db %10101010           ;█ █ █ █ █
4194         .db %10110101           ;█ ██ █ ██
4195         .db %10101010           ;█ █ █ █ █
4196         .db %10111111           ;█ ███████
4197         .db %10000000           ;█
4198         .db 6
4199         .db %00000000
4200         .db %10000000
4201         .db %10000000
4202         .db %10000000
4203         .db %10000000
4204         .db %10000000
4205 maxarmor = 63                           ;maximum HPs you can get
4206 spr_icon03:
4207         .db 5,7         ;laser   .......:.......:
4208         .db %10000000           ;█         ▒
4209         .db %10100000           ;█ █   ▒▒▒ ▒
4210         .db %10100000           ;█ █   ▒▒▒ ▒
4211         .db %10100000           ;█ █   ▒▒▒ ▒
4212         .db %10100000           ;█ █   ▒▒▒ ▒
4213         .db %10111000           ;█ ███ ▒▒▒ ▒
4214         .db %10000000           ;█         ▒
4215 spr_icon04:
4216         .db 5,7         ;bullets .......:.......:
4217         .db %10000000           ;█         ▒
4218         .db %10110000           ;█ ██  ▒▒▒ ▒
4219         .db %10101000           ;█ █ █ ▒▒▒ ▒
4220         .db %10110000           ;█ ██  ▒▒▒ ▒
4221         .db %10101000           ;█ █ █ ▒▒▒ ▒
4222         .db %10110000           ;█ ██  ▒▒▒ ▒
4223         .db %10000000           ;█         ▒
4224 spr_icon05:
4225         .db 7,7         ;multiple.......:.......:
4226         .db %10000000           ;█          ▒
4227         .db %10100010           ;█ █   █    ▒
4228         .db %10110110           ;█ ██ ██    ▒
4229         .db %10101010           ;█ █ █ █    ▒
4230         .db %10100010           ;█ █   █    ▒
4231         .db %10100010           ;█ █   █    ▒
4232         .db %10000000           ;█          ▒
4233
4234 #endif
4235
4236 spr_dividerline:
4237         .db 8,7
4238         .db 128,128,128,128,128,128,128 ;128 = %10000000
4239
4240 ;---------------------------- texts ------------------------------------------
4241
4242 #ifdef TI83
4243 txt_email:      .db 127," www.shiar.org ",127,0 ;title screen
4244 _txt_email        = $3A20
4245 txt_about:      .db "v1.0.C21 ",127," by Shiar",0 ;right behind txt_email
4246 _txt_about        = $3311
4247 #endif
4248 #ifdef TI86
4249 txt_email:      .db "www.shiar.org ",127 ;title screen
4250                 .db " shiar0@hotmail.com",0
4251 _txt_email        = $3A01 ;$3A1E=just email
4252 txt_about:      .db "v1.0.C21 ",127," by Shiar",0 ;right behind txt_email
4253 _txt_about        = $3321
4254 #endif
4255
4256 txt_menu1:      .db "NEW GAME",0
4257 txt_menu2:      .db "CONTINUE",0
4258
4259 txt_difhardcore:.db "Hardcore!",0
4260 txt_difnormal:  .db "Normal",0
4261 txt_shpbeam:    .db "Beam",0
4262 txt_shplaser:   .db "Laser",0
4263
4264 txt_level:      .db "LEVEL ",0 ;new level screen
4265 txt_lives:      .db   "Lx0",0
4266 txt_savekey:    .db "Press [F1] to save",0
4267
4268 txt_gameover:   .db "GAME OVER!",0 ;game over screen
4269 txt_score:      .db "Score",0
4270 txt_hiscore:    .db "Hiscore",0
4271
4272 txt_pause:      .db " ",6,"/",7," ",$1C,"contrast; "
4273                 .db "F1",$1C,"B",$CF,5,"W Mode",0
4274 _txt_pause        = $020B
4275 txt_pressenter: .db "Enter to continue",0 ;pause
4276 _txt_pressenter   = $0201
4277 #ifdef teacherkey
4278 txt_teacher:    .db "(2",Lpi,"*.98)/sin 13",0 ;teacher
4279 txt_teacherans: .db Lneg,"14.6549373495",0
4280 #endif
4281
4282 ;------------------------------ levels data ----------------------------------
4283
4284 ;format:boss: [moveType] [enemyType]
4285 ;       @level: [nr.dif.enemies]x [enemy nr]
4286 ;       [min. enemy frequency] [enemy frequency max.inc]
4287 ;       [next lvl (=nrenemies+4)] [level_info: 0000000 1:ground]
4288 ;       [tunnel size] [groundtype] [stars1] [stars2]
4289 ;efrequency must be odd if halfluring!
4290
4291 #ifdef story
4292         .db 0   ;storyline ID
4293 levelstart:     ;[y-pos] [x-pos] [text,0] [SFX lines; 0=more text] [-1=end]
4294         .db 28,35,"COSMIC YEAR 6718",0,28-28+6
4295         .db 10,8,"INTELLIGENCE REPORTS ",
4296         .db     "BACTERION",0,0
4297         .db 17,7,"FORCES ARE BUILDING A ",
4298         .db     "NEW VESSEL",0,0
4299         .db 33,32,"A POWERFUL VESSEL",0,0
4300         .db 40,15,"THAT COULD EASILY DESTROY",
4301         .db     " US",0,0
4302         .db 47,36,"ONCE COMPLETED",0,47-10+6
4303
4304         .db 22,1,"YOU HAVE TO GO INTO THE ",
4305         .db     "HEART OF THEIR",0,0
4306         .db 28,1,"SPACE AND DESTROY THE VESSEL",
4307         .db     " BEFORE",0,0
4308         .db 34,22,"IT BECOMES OPERATIONAL.",0,34-22+6
4309         .db 25,56,"GOOD",0,0
4310         .db 32,56,"LUCK",0,32-25+6
4311         .db -1
4312 #endif
4313         .db 40
4314 #ifndef story
4315 levelstart:
4316 #endif
4317 level00: ;intro
4318         .db 5,3,5,3,2,2
4319         .db 28,73,13
4320         .db %0,0,1,1
4321
4322         .db 41
4323 level01:.db 2,3,5
4324         .db 26,70,20
4325         .db %0,0,1,1
4326
4327         .db 42
4328 level02:.db 3,3,4,5
4329         .db 20,60,60
4330         .db %0,0,1,1
4331
4332         .db 43
4333 level03:.db 4,4,5,6,7
4334         .db 17,40,75
4335         .db %0,0,1,1
4336 #ifdef story
4337         .db 0
4338         .db 25,2,"LONG-RANGE SCANNERS ARE ",
4339         .db     "SHOWING",0,0
4340         .db 32,2,"LOTS OF ENEMY VESSELS ",
4341         .db     "APPROACHING",0,32-25+6
4342         .db 22,9,"I'M CHANGING COURSE TO A",
4343         .db     " NEARBY",0,0
4344         .db 28,4,"ASTEROID BELT AND TRY TO ",
4345         .db     "LOSE THEM",0,0
4346         .db 34,48,"INTHERE...",0,34-22+6
4347         .db -1
4348 #endif
4349         .db 44
4350 level04: ;approaching asteroid belt
4351         .db 5,8,8,9,11,12
4352         .db 17,27,70
4353         .db %0,0,1,1
4354
4355         .db 45
4356 level05: ;inside belt
4357         .db 7,10,11,9,11,12,12,14
4358         .db 12,24,80
4359         .db %0,0,1,1
4360
4361         .db 46
4362 level06: ;(deep inside)
4363         .db 10,10,11,12,12,14,13,13,14,15,15
4364         .db 7,18,180
4365         .db %0,0,1,1
4366 #ifdef story
4367         .db 0
4368         .db 28,6,"APPROACHING BACTERION ",
4369         .db     "TERRATORY",0,6
4370         .db 25,10,"READING LOTS OF ENEMY ",
4371         .db     "VESSELS",0,0
4372         .db 32,24,"ON AN INTERCEPT COURSE",0,32-25+6
4373         .db -1
4374 #endif
4375         .db 47
4376 level07:.db 4,16,17,18,6
4377         .db 22,29,62
4378         .db %0,0,1,1 ;-1=%11111111=line
4379
4380         .db 48
4381 level08:.db 5,16,17,18,19,19
4382         .db 20,38,57
4383         .db %0,0,1,1
4384
4385         .db 49
4386 level09: ;lot of triples
4387         .db 3,19,20,21
4388         .db 19,63,57
4389         .db %0,0,1,1
4390
4391         .db 50
4392 level10: ;likely no pickups here (hard)
4393         .db 7,22,23,24,24,24,25,26
4394         .db 22,26,51
4395         .db %0,0,1,1
4396 #ifdef story
4397         .db 0
4398         .db 24,18,"REACHED THEIR HOMEPLANET",0,0
4399         .db 33,18,"SCANNING FOR THE VESSEL...",0,33-24+6
4400         .db -1
4401 #endif
4402         .db 50
4403 level11: ;planet level
4404         .db 8,27,27,28,28,29,29,29,30
4405         .db 6,8,108
4406         .db %1,-7,-1,-1
4407
4408         .db 50
4409 level12: ;planet level 2
4410         .db 4,39,30,31,31
4411         .db 16,8,49
4412         .db %1,-10,1,1
4413 #ifdef story
4414         .db 0
4415         .db 18,11,"ENEMY VESSEL STRAIGHT "
4416         .db     "AHEAD...",0,0
4417         .db 25,16,"IT SEEMS TO BE "
4418         .db     "OPERATIONAL!!",0,0
4419         .db 33,19,"WELL YOU'VE COME THIS "
4420         .db     "FAR;",0,0
4421         .db 39,8,"TRY TO DESTROY IT, OR DIE "
4422         .db     "TRYING....",0,39-18+6
4423         .db -1
4424 #endif
4425         .db 51
4426 level13: ;endlevel
4427         .db 1,26
4428         .db 5,20,18
4429         .db %0,0,1,1
4430 #ifdef story
4431         .db 0
4432         .db 1,1,"Thats all folks...",0,0
4433         .db 20,50,"for now...",0,20-1+6
4434         .db -1
4435 #endif
4436 endlevel = 13+1
4437
4438 pickupfreq = 19
4439
4440 ;------------------------------ enemies --------------------------------------
4441
4442 ;format:        [HP64] [000000:HP 00:occ] [sprite] [xpos] [appearance(ypos)]
4443 ;               [movetype] [time2fire] [firefreq] [firetype]
4444 ;occ:           %00=no enemy; 01=exploding (sprite=frame); 10=pickup; 11=enemy
4445 ;appearances:   0+=ypos; -1=random; -2=lure; -3=halflure
4446 ;movetypes:     0=1x; 1=updown; 2=0.25x; 3=0.5x; 4=0.75x; 5=1.25x; 6=1.5x;
4447 ;               7=2x; 8=3x; 9=ylure50%; 10=ylure; 11=ylure50%; 12=x+y-lure 50%;
4448 ;               13=-1/2x; 14=-1x; 16=boss; 17=right+1
4449 ;firetypes:     1=normal; 2=down; 3=up; 4=1/2down; 5=1/2up; 6=aiming(2-5);
4450 ;               7=triple; 8=double; 9=wide5; 10=wide7; 11=ran; 12=10+enemies
4451 ;               13=base; 14=ranY; 15=wide3; 16=5x
4452
4453 enemyspecs:  ;10 bytes/enemy | max.enemies <64 | sprites use <768 bytes
4454 #ifdef TI86
4455 ;0-1=pickups
4456         .db  0,%00000010,spr_enemyP1&255,spr_enemyP1/256,128,-2,03, 0, 0,1 ;pickup
4457         .db  0,%00000110,spr_enemyP2&255,spr_enemyP2/256,128,-2,03, 0, 0,1 ;bigpickup
4458 ;2-7=basic enemies      ,spr_enemy  &255,spr_enemy  /256,  X, Y, d,WT,WF,W
4459         .db  0,%00001011,spr_enemyE0&255,spr_enemyE0/256,128,-1,00,12, 0,1 ;intro
4460         .db  0,%00100011,spr_enemyE1&255,spr_enemyE1/256,128,-1,00,10, 0,1 ;weak
4461         .db  0,%01100011,spr_enemyE4&255,spr_enemyE4/256,128,-1,03, 6,50,1 ;slow
4462         .db  0,%01001011,spr_enemyE2&255,spr_enemyE2/256,128,-1,00, 1, 0,1
4463         .db  0,%01011011,spr_enemyE3&255,spr_enemyE3/256,128,-3,00,19,39,8 ;heavy
4464         .db  0,%01010011,spr_enemyE5&255,spr_enemyE5/256,128,-3,05, 1, 0,1 ;fast
4465 ;8-10=backwards enemies ,spr_enemy  &255,spr_enemy  /256,  X, Y, d,WT,WF,W
4466         .db  0,%00111011,spr_enemyB1&255,spr_enemyB1/256,000,-3,13,19,92,1
4467         .db  0,%01011011,spr_enemyB2&255,spr_enemyB2/256,000,-1,14,11,45,1
4468         .db  0,%01101011,spr_enemyB3&255,spr_enemyB3/256,000,-1,13,10,41,8 ;small
4469 ;11-15=asteroid         ,spr_enemy  &255,spr_enemy  /256,  X, Y, d,WT,WF,W
4470         .db  0,%01001011,spr_enemyA1&255,spr_enemyA1/256,128,-1,04, 0, 0,1
4471         .db  0,%01111011,spr_enemyA2&255,spr_enemyA2/256,128,-1,00, 0, 0,1
4472         .db  0,%10110011,spr_enemyA3&255,spr_enemyA3/256,128,-1,06, 0, 0,1
4473         .db  1,%00010011,spr_enemyA4&255,spr_enemyA4/256,128,-1,03, 0, 0,1 ;slow+hard
4474         .db  0,%01111011,spr_enemyA4&255,spr_enemyA4/256,128,-1,07, 0, 0,1
4475 ;16-21=improved enemies ,spr_enemy  &255,spr_enemy  /256,  X, Y, d,WT,WF,W
4476         .db  0,%10010011,spr_enemyG1&255,spr_enemyG1/256,128,-3,00, 3,40,1
4477         .db  0,%10111011,spr_enemyG2&255,spr_enemyG2/256,128,-3,00, 1,36,1
4478         .db  0,%01100011,spr_enemyG5&255,spr_enemyG5/256,128,-1,01, 9,52,1 ;updown
4479         .db  0,%11110011,spr_enemyG3&255,spr_enemyG3/256,128,-3,04, 7,99,15 ;3x
4480         .db  1,%01101011,spr_enemyG4&255,spr_enemyG4/256,128,-2,01,17, 0,15 ;updown3x
4481         .db  1,%00010011,spr_enemyG6&255,spr_enemyG6/256,128,-2,09,62,60,8 ;lure
4482 ;22-26=hi-speed         ,spr_enemy  &255,spr_enemy  /256,  X, Y, d,WT,WF,W
4483         .db  1,%00010011,spr_enemyS2&255,spr_enemyS2/256,128,-2,06, 3,32,8 ;fast
4484         .db  0,%11111011,spr_enemyS1&255,spr_enemyS1/256,128,-3,09, 2,28,1 ;lure
4485         .db  1,%00101011,spr_enemyS4&255,spr_enemyS4/256,128,-3,07, 0, 0,1 ;vfast+nofire
4486         .db  1,%01110011,spr_enemyS3&255,spr_enemyS3/256,128,-1,09, 1,20,8 ;lure+
4487         .db  0,%11011011,spr_enemyS2&255,spr_enemyS2/256,128,-2,01, 3,7,11 ;updown+ran
4488 ;27-29=hyper  ,%        ,spr_enemy  &255,spr_enemy  /256,  X, Y, d,WT,WF,W
4489         .db  1,%00001011,spr_enemyN1&255,spr_enemyN1/256,128,-1,07, 0, 0,1
4490         .db  1,%00010111,spr_enemyN2&255,spr_enemyN2/256,128,-2,07, 0, 0,1
4491         .db  1,%00001111,spr_enemyN3&255,spr_enemyN3/256,128,-1,08, 0, 0,1 ;xfast
4492 ;30-31=turrets,%        ,spr_enemy  &255,spr_enemy  /256,  X, Y, d,WT,WF,W
4493         .db  1,%10001111,spr_enemyT1&255,spr_enemyT1/256,128,-4,00, 1,15,3 ;turret L
4494         .db  1,%11011011,spr_enemyT1&255,spr_enemyT1/256,128,-4,00, 1,16,5 ;turret l
4495
4496         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,128, 0, 0, 0, 0,0
4497         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,128, 0, 0, 0, 0,0
4498         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,128, 0, 0, 0, 0,0
4499         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,128, 0, 0, 0, 0,0
4500         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,128, 0, 0, 0, 0,0
4501 ;37-38=final boss' enemy,spr_enemy  &255,spr_enemy  /256,  X, Y, d,WT,WF,W
4502         .db  0,%11110011,spr_enemyM1&255,spr_enemyM1/256,128,-3,01, 0, 0,1 ;moving
4503         .db  0,%11110011,spr_enemyM1&255,spr_enemyM1/256,128,23,11, 0, 0,1 ;mid+lure
4504 ;39=misc      ,%        ,spr_enemy  &255,spr_enemy  /256,  X, Y, d,WT,WF,W
4505         .db -1,%11111111,spr_enemyM2&255,spr_enemyM2/256,128,-2,08, 0, 0,1 ;bullet
4506 boss1enemy = 37
4507 boss2enemy = 38
4508 ;40-44=first bosses     ,spr_      &255,spr_       /256,  X, Y, d,WT,WF,W
4509         .db  2,%01000111,spr_boss01&255,spr_boss01 /256,127,-1,11,35,48,15 ;triple
4510         .db  2,%01010011,spr_boss02&255,spr_boss02 /256,127,-1,11,20,12,1  ;single
4511         .db  2,%11011011,spr_boss03&255,spr_boss03 /256,127,-1,10,15, 8,8  ;double
4512         .db  3,%00111111,spr_boss04&255,spr_boss04 /256,127,-3,12,10,11,1  ;Flure
4513         .db  4,%01011011,spr_boss05&255,spr_boss05 /256,000,-2,17, 1,3,11  ;ranfire
4514 ;45-46=asteroid bosses  ,spr_      &255,spr_       /256,  X, Y,  ,  ,  ,
4515         .db  5,%01101111,spr_bossA1&255,spr_bossA1 /256,127,-2,12,28,14,7  ;Flure
4516         .db 20,%00011111,spr_bossA2&255,spr_bossA2 /256,119,00,16,31, 3,14 ;fullscreen
4517 ;47-51=big bosses       ,spr_      &255,spr_       /256,  X, Y,  ,  ,  ,
4518         .db  4,%00010111,spr_boss07&255,spr_boss07 /256,127,-3,10,31, 8,16 ;5x
4519         .db  6,%10001111,spr_boss08&255,spr_boss08 /256,127,-1,10,18, 8,9  ;quad
4520         .db  3,%10111011,spr_boss06&255,spr_boss06 /256,127,-2,12, 1, 4,1  ;weak+rapidfire
4521         .db  7,%11101011,spr_boss09&255,spr_boss09 /256,127,-1,10,21, 9,10 ;6x
4522         .db  9,%11011011,spr_boss10&255,spr_boss10 /256,127,-1,10,12,11,12 ;enemies
4523 #else
4524 ;0-1=pickups
4525         .db  0,%00000010,spr_enemyP1&255,spr_enemyP1/256,96,-2,03, 0, 0,1 ;pickup
4526         .db  0,%00000110,spr_enemyP2&255,spr_enemyP2/256,96,-2,03, 0, 0,1 ;bigpickup
4527 ;2-7=basic enemies      ,spr_enemy  &255,spr_enemy  /256, X, Y, d,WT,WF,W
4528         .db  0,%00001011,spr_enemyE0&255,spr_enemyE0/256,96,-1,00,12, 0,1 ;intro
4529         .db  0,%00100011,spr_enemyE1&255,spr_enemyE1/256,96,-1,00,10, 0,1 ;weak
4530         .db  0,%01100011,spr_enemyE4&255,spr_enemyE4/256,96,-1,03, 6,50,1 ;slow
4531         .db  0,%01001011,spr_enemyE2&255,spr_enemyE2/256,96,-1,00, 1, 0,1
4532         .db  0,%01011011,spr_enemyE3&255,spr_enemyE3/256,96,-3,00,19,39,8 ;heavy
4533         .db  0,%01010011,spr_enemyE5&255,spr_enemyE5/256,96,-3,05, 1, 0,1 ;fast
4534 ;8-10=backwards enemies ,spr_enemy  &255,spr_enemy  /256, X, Y, d,WT,WF,W
4535         .db  0,%00111011,spr_enemyB1&255,spr_enemyB1/256,00,-3,13,19,92,1
4536         .db  0,%01011011,spr_enemyB2&255,spr_enemyB2/256,00,-1,14,11,45,1
4537         .db  0,%01101011,spr_enemyB3&255,spr_enemyB3/256,00,-1,13,10,41,8 ;small
4538 ;11-15=asteroid         ,spr_enemy  &255,spr_enemy  /256, X, Y, d,WT,WF,W
4539         .db  0,%01001011,spr_enemyA1&255,spr_enemyA1/256,96,-1,04, 0, 0,1
4540         .db  0,%01111011,spr_enemyA2&255,spr_enemyA2/256,96,-1,00, 0, 0,1
4541         .db  0,%10110011,spr_enemyA3&255,spr_enemyA3/256,96,-1,06, 0, 0,1
4542         .db  1,%00010011,spr_enemyA4&255,spr_enemyA4/256,96,-1,03, 0, 0,1 ;slow+hard
4543         .db  0,%01111011,spr_enemyA4&255,spr_enemyA4/256,96,-1,07, 0, 0,1
4544 ;16-21=improved enemies ,spr_enemy  &255,spr_enemy  /256, X, Y, d,WT,WF,W
4545         .db  0,%10010011,spr_enemyG1&255,spr_enemyG1/256,96,-3,00, 3,40,1
4546         .db  0,%10111011,spr_enemyG2&255,spr_enemyG2/256,96,-3,00, 1,36,1
4547         .db  0,%01100011,spr_enemyG5&255,spr_enemyG5/256,96,-1,01, 9,52,1 ;updown
4548         .db  0,%11110011,spr_enemyG3&255,spr_enemyG3/256,96,-3,04, 7,99,15 ;3x
4549         .db  1,%01101011,spr_enemyG4&255,spr_enemyG4/256,96,-2,01,17, 0,15 ;updown3x
4550         .db  1,%00010011,spr_enemyG6&255,spr_enemyG6/256,96,-2,09,62,60,8 ;lure
4551 ;22-26=hi-speed         ,spr_enemy  &255,spr_enemy  /256, X, Y, d,WT,WF,W
4552         .db  1,%00010011,spr_enemyS2&255,spr_enemyS2/256,96,-2,06, 3,32,8 ;fast
4553         .db  0,%11111011,spr_enemyS1&255,spr_enemyS1/256,96,-3,09, 2,28,1 ;lure
4554         .db  1,%00101011,spr_enemyS4&255,spr_enemyS4/256,96,-3,07, 0, 0,1 ;vfast+nofire
4555         .db  1,%01110011,spr_enemyS3&255,spr_enemyS3/256,96,-1,09, 1,20,8 ;lure+
4556         .db  0,%11011011,spr_enemyS2&255,spr_enemyS2/256,96,-2,01, 3,7,11 ;updown+ran
4557 ;27-29=hyper  ,%        ,spr_enemy  &255,spr_enemy  /256, X, Y, d,WT,WF,W
4558         .db  1,%00001011,spr_enemyN1&255,spr_enemyN1/256,96,-1,07, 0, 0,1
4559         .db  1,%00010111,spr_enemyN2&255,spr_enemyN2/256,96,-2,07, 0, 0,1
4560         .db  1,%00001111,spr_enemyN3&255,spr_enemyN3/256,96,-1,08, 0, 0,1 ;xfast
4561 ;30-31=turrets,%        ,spr_enemy  &255,spr_enemy  /256, X, Y, d,WT,WF,W
4562         .db  1,%10001111,spr_enemyT1&255,spr_enemyT1/256,96,-4,00, 1,15,3 ;turret L
4563         .db  1,%11011011,spr_enemyT1&255,spr_enemyT1/256,96,-4,00, 1,16,5 ;turret l
4564
4565         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,96, 0, 0, 0, 0,0
4566         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,96, 0, 0, 0, 0,0
4567         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,96, 0, 0, 0, 0,0
4568         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,96, 0, 0, 0, 0,0
4569         .db  0,%00000011,spr_enemy00&255,spr_enemy00/256,96, 0, 0, 0, 0,0
4570 ;37-38=final boss' enemy,spr_enemy  &255,spr_enemy  /256, X, Y, d,WT,WF,W
4571         .db  0,%11110011,spr_enemyM1&255,spr_enemyM1/256,96,-3,01, 0, 0,1 ;moving
4572         .db  0,%11110011,spr_enemyM1&255,spr_enemyM1/256,96,23,11, 0, 0,1 ;mid+lure
4573 ;39=misc      ,%        ,spr_enemy  &255,spr_enemy  /256, X, Y, d,WT,WF,W
4574         .db -1,%11111111,spr_enemyM2&255,spr_enemyM2/256,96,-2,08, 0, 0,1 ;bullet
4575 boss1enemy = 37
4576 boss2enemy = 38
4577 ;40-44=first bosses     ,spr_      &255,spr_       /256, X, Y, d,WT,WF,W
4578         .db  2,%01000111,spr_boss01&255,spr_boss01 /256,95,-1,11,35,48,15 ;triple
4579         .db  2,%01010011,spr_boss02&255,spr_boss02 /256,95,-1,11,20,12,1  ;single
4580         .db  2,%11011011,spr_boss03&255,spr_boss03 /256,95,-1,10,15, 8,8  ;double
4581         .db  3,%00111111,spr_boss04&255,spr_boss04 /256,95,-3,12,10,11,1  ;Flure
4582         .db  4,%01011011,spr_boss05&255,spr_boss05 /256,00,-2,17, 1,3,11  ;ranfire
4583 ;45-46=asteroid bosses  ,spr_      &255,spr_       /256, X, Y,  ,  ,  ,
4584         .db  5,%01101111,spr_bossA1&255,spr_bossA1 /256,95,-2,12,28,14,7  ;Flure
4585         .db 20,%00011111,spr_bossA2&255,spr_bossA2 /256,87,00,16,31, 3,14 ;fullscreen
4586 ;47-51=big bosses       ,spr_      &255,spr_       /256, X, Y,  ,  ,  ,
4587         .db  4,%00010111,spr_boss07&255,spr_boss07 /256,95,-3,10,31, 8,16 ;5x
4588         .db  6,%10001111,spr_boss08&255,spr_boss08 /256,95,-1,10,18, 8,9  ;quad
4589         .db  3,%10111011,spr_boss06&255,spr_boss06 /256,95,-2,12, 1, 4,1  ;weak+rapidfire
4590         .db  7,%11101011,spr_boss09&255,spr_boss09 /256,95,-1,10,21, 9,10 ;6x
4591         .db  9,%11011011,spr_boss10&255,spr_boss10 /256,95,-1,10,12,11,12 ;enemies
4592 #endif
4593
4594 spr_enemy00:
4595 spr_enemyP1:
4596         .db 10,8                        ;pickup
4597         .db %00111111                   ;  ██████
4598         .db %01100001                   ; ██    ██
4599         .db %10001100                   ;█   ██   █
4600         .db %10111111                   ;█ ██████ █
4601         .db %10111111                   ;█ ██████ █
4602         .db %10001100                   ;█   ██   █
4603         .db %01100001                   ; ██    ██
4604         .db %00111111                   ;  ██████
4605         .db 7
4606         .db %00000000
4607         .db %10000000
4608         .db %01000000
4609         .db %01000000
4610         .db %01000000
4611         .db %01000000
4612         .db %10000000
4613 spr_enemyP2:
4614         .db 11,9                        ;big pickup
4615         .db %00111111                   ;  ███████
4616         .db %01100000                   ; ██     ██
4617         .db %10001110                   ;█   ███   █
4618         .db %10111011                   ;█ ███ ███ █
4619         .db %10100000                   ;█ █     █ █
4620         .db %10111011                   ;█ ███ ███ █
4621         .db %10001110                   ;█   ███   █
4622         .db %01100000                   ; ██     ██
4623         .db %00111111                   ;  ███████
4624         .db 9
4625         .db %10000000
4626         .db %11000000
4627         .db %00100000
4628         .db %10100000
4629         .db %10100000
4630         .db %10100000
4631         .db %00100000
4632         .db %11000000
4633         .db %10000000
4634
4635 spr_enemyE0:
4636         .db 6,7                         ;weak
4637         .db %00011100                   ;   ███
4638         .db %00100100                   ;  █  █
4639         .db %01101000                   ; ██ █
4640         .db %10110100                   ;█ ██ █
4641         .db %01101000                   ; ██ █
4642         .db %00100100                   ;  █  █
4643         .db %00011100                   ;   ███
4644 spr_enemyE1:
4645         .db 6,7                         ;weak
4646         .db %00111100                   ;  ████
4647         .db %01000100                   ; █   █
4648         .db %10111000                   ;█ ███
4649         .db %11100000                   ;███
4650         .db %10111000                   ;█ ███
4651         .db %01000100                   ; █   █
4652         .db %00111100                   ;  ████
4653 spr_enemyE2:
4654         .db 6,6                         ;weak
4655         .db %00111100                   ;  ████
4656         .db %01010000                   ; █ █
4657         .db %10100000                   ;█ █
4658         .db %10100000                   ;█ █
4659         .db %01010000                   ; █ █
4660         .db %00111100                   ;  ████
4661 spr_enemyE3:
4662         .db 6,6                         ;normal solid (Galaxian enemy)
4663         .db %00111100                   ;  ████
4664         .db %01010000                   ; █ █
4665         .db %11010000                   ;██ █
4666         .db %11010000                   ;██ █
4667         .db %01010000                   ; █ █
4668         .db %00111100                   ;  ████
4669 spr_enemyE4:
4670         .db 6,7
4671         .db %00011100                   ;   ███
4672         .db %01101000                   ; ██ █
4673         .db %10011000                   ;█  ██
4674         .db %01110000                   ; ███
4675         .db %10011000                   ;█  ██
4676         .db %01101000                   ; ██ █
4677         .db %00011100                   ;   ███
4678 spr_enemyE5:
4679         .db 6,6                         ;speedy
4680         .db %00010100                   ;   █ █
4681         .db %01111000                   ; ████
4682         .db %10100000                   ;█ █
4683         .db %10100000                   ;█ █
4684         .db %01111000                   ; ████
4685         .db %00010100                   ;   █ █
4686
4687 spr_enemyB1:
4688         .db 6,6                         ;solid backwards
4689         .db %11110000                   ;████
4690         .db %00101000                   ;  █ █
4691         .db %01010100                   ; █ █ █
4692         .db %01010100                   ; █ █ █
4693         .db %00101000                   ;  █ █
4694         .db %11110000                   ;████
4695 spr_enemyB2:
4696         .db 6,7
4697         .db %11110000                   ;████
4698         .db %01001000                   ; █  █
4699         .db %01110100                   ; ███ █
4700         .db %00100100                   ;  █  █
4701         .db %01110100                   ; ███ █
4702         .db %01001000                   ; █  █
4703         .db %11110000                   ;████
4704 spr_enemyB3:
4705         .db 5,7
4706         .db %11100000                   ;███
4707         .db %01010000                   ; █ █
4708         .db %01111000                   ; ████
4709         .db %01000000                   ; █
4710         .db %01111000                   ; ████
4711         .db %01010000                   ; █ █
4712         .db %11100000                   ;███
4713
4714 spr_enemyA1:
4715         .db 7,6                         ;asteroid one
4716         .db %00011000                   ;   ██
4717         .db %01101100                   ; ██ ██
4718         .db %10011110                   ;█  ████
4719         .db %11111010                   ;█████ █
4720         .db %10111100                   ;█ ████
4721         .db %01110000                   ; ███
4722 spr_enemyA2:
4723         .db 8,7                         ;asteroid two
4724         .db %00111100                   ;  ████
4725         .db %01011010                   ; █ ██ █
4726         .db %01101101                   ; ██ ██ █
4727         .db %11111101                   ;██████ █
4728         .db %11111111                   ;████████
4729         .db %10110110                   ;█ ██ ██
4730         .db %01100000                   ; ██
4731 spr_enemyA3:
4732         .db 8,8                         ;asteroid three
4733         .db %00011110                   ;   ████
4734         .db %01110011                   ; ███  ██
4735         .db %01111101                   ; █████ █
4736         .db %10110111                   ;█ ██ ███
4737         .db %11111110                   ;███████
4738         .db %11111101                   ;██████ █
4739         .db %01010111                   ; █ █ ███
4740         .db %00001110                   ;    ███
4741 spr_enemyA4:
4742         .db 7,6                         ;asteroid four
4743         .db %01111000                   ; ████
4744         .db %10110110                   ;█ ██ ██
4745         .db %11111101                   ;██████ █
4746         .db %01111011                   ; ████ ██
4747         .db %01001110                   ; █  ███
4748         .db %00110000                   ;  ██
4749
4750 spr_enemyG1:
4751         .db 8,6                         ;G-Type
4752         .db %00011111                   ;   █████
4753         .db %01001000                   ; █  █
4754         .db %10110100                   ;█ ██ █
4755         .db %10110100                   ;█ ██ █
4756         .db %01001000                   ; █  █
4757         .db %00011111                   ;   █████
4758 spr_enemyG2:
4759         .db 8,6                         ;smaller nacelles
4760         .db %00010111                   ;   █ ███
4761         .db %01101100                   ; ██ ██
4762         .db %10110100                   ;█ ██ █
4763         .db %10110100                   ;█ ██ █
4764         .db %01101100                   ; ██ ██
4765         .db %00010111                   ;   █ ███
4766 spr_enemyG3:
4767         .db 8,6                         ;shuttle
4768         .db %00001111                   ;    ████
4769         .db %01110100                   ; ███ █
4770         .db %10011100                   ;█  ███
4771         .db %10011100                   ;█  ███
4772         .db %01110100                   ; ███ █
4773         .db %00001111                   ;    ████
4774 spr_enemyG4:
4775         .db 8,6                         ;G-Type solid
4776         .db %00111101                   ;   ███ █
4777         .db %01111000                   ; ████
4778         .db %11110100                   ;████ █
4779         .db %11110100                   ;████ █
4780         .db %01111000                   ; ████
4781         .db %00111101                   ;   ███ █
4782 spr_enemyG5:
4783         .db 6,6
4784         .db %01111100                   ; █████
4785         .db %10110000                   ;█ ██
4786         .db %10101000                   ;█ █ █
4787         .db %10101000                   ;█ █ █
4788         .db %10110000                   ;█ ██
4789         .db %01111100                   ; █████
4790 spr_enemyG6:
4791         .db 8,5                         ;shuttle
4792         .db %00001111                   ;    ████
4793         .db %01110100                   ; ███ █
4794         .db %10011010                   ;█  ██ █
4795         .db %01110100                   ; ███ █
4796         .db %00001111                   ;    ████
4797
4798 spr_enemyS1:
4799         .db 6,6                         ;solid
4800         .db %00111000                   ;   ███
4801         .db %01111100                   ;  █████
4802         .db %11111000                   ; █████
4803         .db %11111000                   ; █████
4804         .db %01111100                   ;  █████
4805         .db %00111000                   ;   ███
4806 spr_enemyS2:
4807         .db 7,6                         ;some attack vessel
4808         .db %00011100                   ;    ███
4809         .db %01110010                   ;  ███  █
4810         .db %10101100                   ; █ █ ██
4811         .db %10101100                   ; █ █ ██
4812         .db %01110010                   ;  ███  █
4813         .db %00011100                   ;    ███
4814 spr_enemyS3:
4815         .db 7,6                         ;interceptor
4816         .db %00011110                   ;    ████
4817         .db %01111110                   ;  ██████
4818         .db %11111100                   ; ██████
4819         .db %11111100                   ; ██████
4820         .db %01111110                   ;  ██████
4821         .db %00011110                   ;    ████
4822 spr_enemyS4:
4823         .db 8,6                         ;fast interceptor
4824         .db %00011011                   ;    ██ ██
4825         .db %01110110                   ;  ███ ██
4826         .db %10111100                   ; █ ████
4827         .db %10111100                   ; █ ████
4828         .db %01110110                   ;  ███ ██
4829         .db %00011011                   ;    ██ ██
4830
4831 spr_enemyN1:
4832         .db 8,7                         ;some cool Nemesis-MSX enemy
4833         .db %00111110                   ;  █████
4834         .db %11110001                   ;████   █
4835         .db %00001110                   ;    ███
4836         .db %00010101                   ;   █ █ █
4837         .db %00001110                   ;    ███
4838         .db %11110001                   ;████   █
4839         .db %00111110                   ;  █████
4840 spr_enemyN2:
4841         .db 8,7                         ;
4842         .db %00111110                   ;  █████
4843         .db %00011101                   ;   ███ █
4844         .db %11111111                   ;████ ███
4845         .db %01110110                   ; ██ ███
4846         .db %11111111                   ;████ ███
4847         .db %00011101                   ;   ███ █
4848         .db %00111110                   ;  █████
4849 spr_enemyN3:
4850         .db 8,7                         ;Nem3MSX jumper lvl#3
4851         .db %10111110                   ;█ █████
4852         .db %01011101                   ; █ ███ █
4853         .db %01111110                   ; ██████
4854         .db %00010100                   ;   █ █
4855         .db %01111110                   ; ██████
4856         .db %01011101                   ; █ ███ █
4857         .db %10111110                   ;█ █████
4858 spr_enemyN4:
4859         .db 8,8                         ;Stolen from XC1701II
4860         .db %01111110                   ; ██████
4861         .db %11110101                   ;████ █ █
4862         .db %00011111                   ;   █████
4863         .db %00111101                   ;  ████ █
4864         .db %00111001                   ;  ███  █
4865         .db %00011111                   ;   █████
4866         .db %11110101                   ;████ █ █
4867         .db %01111110                   ; ██████
4868 spr_enemyN5:
4869         .db 7,8                         ;Stolen from XC1701II
4870         .db %00111100                   ;  ████
4871         .db %01010010                   ; █ █  █
4872         .db %11111110                   ;███████
4873         .db %01001010                   ; █  █ █
4874         .db %01011010                   ; █ ██ █
4875         .db %11111110                   ;███████
4876         .db %01010010                   ; █ █  █
4877         .db %01111100                   ;  ████
4878
4879 spr_enemyT1:
4880         .db 8,7                         ;turret left
4881         .db %11000000                   ;██
4882         .db %01100000                   ; ██
4883         .db %00110000                   ;  ██
4884         .db %01011100                   ; █ ███
4885         .db %10110110                   ;█ ██ ██
4886         .db %01011010                   ; █ ██ █
4887         .db %11111111                   ;████████
4888 spr_enemyT2:
4889         .db 8,7                         ;turret right
4890         .db %00000011                   ;      ██
4891         .db %00000110                   ;     ██
4892         .db %00001100                   ;    ██
4893         .db %00111010                   ;  ███ █
4894         .db %01101101                   ; ██ ██ █
4895         .db %01011010                   ; █ ██ █
4896         .db %11111111                   ;████████
4897
4898 spr_enemyM1:
4899         .db 8,7                         ;mine
4900         .db %00111100                   ;  ████
4901         .db %01011010                   ; █ ██ █
4902         .db %11111111                   ;████████
4903         .db %01001010                   ; █  █ █
4904         .db %11111111                   ;████████
4905         .db %01011010                   ; █ ██ █
4906         .db %00111100                   ;  ████
4907 spr_enemyM2:
4908         .db 7,6                         ;giant bullet
4909         .db %00011000                   ;   ██▒
4910         .db %01111110                   ; ██████▒
4911         .db %11111000                   ;█████▒
4912         .db %11111100                   ;██████▒
4913         .db %01111110                   ; ██████▒
4914         .db %00111000                   ;  ███▒
4915
4916 spr_boss01:
4917         .db 9,12                        ;.......:.2.....:
4918         .db %00000111                   ;     ████
4919         .db %00011100                   ;   ███
4920         .db %00101010                   ;  █ █ █
4921         .db %01011011                   ; █ ██ ██
4922         .db %10100110                   ;█ █  ██ █
4923         .db %11010101                   ;██ █ █ █
4924         .db %11010101                   ;██ █ █ █
4925         .db %10100110                   ;█ █  ██ █
4926         .db %01011011                   ; █ ██ ██
4927         .db %00101010                   ;  █ █ █
4928         .db %00011100                   ;   ███
4929         .db %00000111                   ;     ████
4930         .db 12
4931         .db %10000000
4932         .db %00000000
4933         .db %00000000
4934         .db %00000000
4935         .db %10000000
4936         .db %00000000 ;...what a waste of space...
4937         .db %00000000
4938         .db %10000000
4939         .db %00000000
4940         .db %00000000
4941         .db %00000000
4942         .db %10000000
4943 spr_boss02:
4944         .db 12,12                       ;.......:....5..:
4945         .db %00011110                   ;   ████
4946         .db %01100001                   ; ██    ██
4947         .db %10110010                   ;█ ██  █  ██
4948         .db %00000101                   ;     █ ██ █
4949         .db %00001010                   ;    █ █  ██
4950         .db %00011010                   ;   ██ █ █  █
4951         .db %00011010                   ;   ██ █ █  █
4952         .db %00001010                   ;    █ █  ██
4953         .db %00000101                   ;     █ ██ █
4954         .db %10110010                   ;█ ██  █  ██
4955         .db %01100001                   ; ██    ██
4956         .db %00011110                   ;   ████
4957         .db 11
4958         .db %00000000
4959         .db %10000000
4960         .db %01100000
4961         .db %10100000
4962         .db %01100000
4963         .db %10010000
4964         .db %10010000
4965         .db %01100000
4966         .db %10100000
4967         .db %01100000
4968         .db %10000000
4969 spr_boss03:
4970         .db 16,10                       ;.......:.......:
4971         .db %00000001                   ;       ██████ ██
4972         .db %00001110                   ;    ███   █ ███
4973         .db %00110010                   ;  ██  █ ████
4974         .db %01001101                   ; █  ██ ██
4975         .db %11101011                   ;███ █ ██ █
4976         .db %11101011                   ;███ █ ██ █
4977         .db %01001101                   ; █  ██ ██
4978         .db %00110010                   ;  ██  █ ████
4979         .db %00001110                   ;    ███   █ ███
4980         .db %00000001                   ;       ██████ ██
4981         .db 10
4982         .db %11111011
4983         .db %00101110
4984         .db %11110000
4985         .db %10000000
4986         .db %01000000
4987         .db %01000000
4988         .db %10000000
4989         .db %11110000
4990         .db %00101110
4991         .db %11111011
4992 spr_boss04:
4993         .db 16,10                       ;.......:.......:
4994         .db %00000000                   ;           █████
4995         .db %00000000                   ;        ███    █
4996         .db %00000111                   ;     ████ █████
4997         .db %00111101                   ;  ████ █ █ ████
4998         .db %01001010                   ; █  █ █ ██ ███ █
4999         .db %10110110                   ;█ ██ ██ ███  █ █
5000         .db %10110110                   ;█ ██ ██ ███  █ █
5001         .db %01001010                   ; █  █ █ ██ ███ █
5002         .db %00111101                   ;  ████ █ █ ████
5003         .db %00000111                   ;     ████ █████
5004         .db 12                          ;        ███    █
5005         .db %00011111                   ;           █████
5006         .db %11100001
5007         .db %10111110
5008         .db %01011110
5009         .db %11011101
5010         .db %11100101
5011         .db %11100101
5012         .db %11011101
5013         .db %01011110
5014         .db %10111110
5015         .db %11100001
5016         .db %00011111
5017 spr_boss05:
5018         .db 16,10                       ;.......:.......:
5019         .db %11111110                   ;███████
5020         .db %00000011                   ;      ███   ████
5021         .db %00110101                   ;  ██ █ ████    █
5022         .db %01111010                   ; ████ █ █  █ ██
5023         .db %10001101                   ;█   ██ █ ██ ██ █
5024         .db %10001101                   ;█   ██ █ ██ ██ █
5025         .db %01111010                   ; ████ █ █  █ ██
5026         .db %00110101                   ;  ██ █ ████    █
5027         .db %00000011                   ;      ███   ████
5028         .db %11111110                   ;███████
5029         .db 9
5030         .db %00000000
5031         .db %10001111
5032         .db %11100001
5033         .db %10010110
5034         .db %01101101
5035         .db %01101101
5036         .db %10010110
5037         .db %11100001
5038         .db %10001111
5039 spr_bossA1:
5040         .db 12,11                       ;AsteroidBoss one
5041         .db %00011110                   ;   ████
5042         .db %01110011                   ; ███  ███
5043         .db %01111111                   ; ███████ █
5044         .db %01111111                   ; █████████
5045         .db %11111110                   ;███████ ███
5046         .db %11111111                   ;███████████
5047         .db %11111111                   ;████████████
5048         .db %10111110                   ;█ █████ ████
5049         .db %01011111                   ; █ ███████
5050         .db %00110111                   ;  ██ ███
5051         .db %00001110                   ;    ███
5052         .db 9
5053         .db %00000000
5054         .db %10000000
5055         .db %01000000
5056         .db %11000000
5057         .db %11100000
5058         .db %11100000
5059         .db %11110000
5060         .db %11110000
5061         .db %11000000
5062 spr_boss06:
5063         .db 16,10                       ;.......:.......:
5064         .db %10111110                   ;█ █████   ███
5065         .db %00000011                   ;      ███   ████
5066         .db %01110101                   ; ███ █ ████ ██ █
5067         .db %11111101                   ;██████ █ ███  █
5068         .db %00000110                   ;     ██ █ █ ██ █
5069         .db %00000110                   ;     ██ █ █ ██ █
5070         .db %11111101                   ;██████ █ ███  █
5071         .db %01110101                   ; ███ █ ████ ██ █
5072         .db %00000011                   ;      ███   ████
5073         .db %10111110                   ;█ █████   ███
5074         .db 10
5075         .db %00111000
5076         .db %10001111
5077         .db %11101101
5078         .db %01110010
5079         .db %10101101
5080         .db %10101101
5081         .db %01110010
5082         .db %11101101
5083         .db %10001111
5084         .db %00111000
5085 spr_boss07:                             ;modelled after a Nemesis][MSX boss
5086         .db 16,15                       ;.......:.......:
5087         .db %00001111                   ;    █████
5088         .db %00111110                   ;  █████ █████
5089         .db %01111101                   ; █████ █ ███████
5090         .db %00000011                   ;      ██
5091         .db %00000100                   ;     █  █
5092         .db %00000011                   ;      █████
5093         .db %00011110                   ;   ████ ██ ████
5094         .db %11110011                   ;████  ██ █ █
5095         .db %00011110                   ;   ████ ██ ████
5096         .db %00000011                   ;      █████
5097         .db %00000100                   ;     █  █
5098         .db %00000011                   ;      ██
5099         .db %01111101                   ; █████ █ ███████
5100         .db %00111110                   ;  █████ █████
5101         .db %00001111                   ;    █████
5102         .db 15
5103         .db %10000000
5104         .db %11111000
5105         .db %01111111
5106         .db %00000000
5107         .db %10000000
5108         .db %11100000
5109         .db %11011110
5110         .db %01010000
5111         .db %11011110
5112         .db %11100000
5113         .db %10000000
5114         .db %00000000
5115         .db %01111111
5116         .db %11111000
5117         .db %10000000
5118 spr_boss08:                             ;modelled after a Nemesis][MSX boss
5119         .db 16,18                       ;.......:.......:
5120         .db %00000000                   ;         █ █
5121         .db %00000111                   ;     ███ ███
5122         .db %00000011                   ;      ████ █
5123         .db %00000001                   ;       ██ ██
5124         .db %00000011                   ;      ███ ██
5125         .db %00000000                   ;        █████
5126         .db %00010111                   ;   █ ██████████
5127         .db %00111111                   ;  ██████ ██ ██
5128         .db %11111000                   ;█████   ██ █ ███
5129         .db %00001111                   ;    █████ ██ █ █
5130         .db %11111000                   ;█████   ██ █ ███
5131         .db %00111111                   ;  ██████ ██ ██
5132         .db %00010111                   ;   █ ██████████
5133         .db %00000000                   ;        █████
5134         .db %00000011                   ;      ███ ██
5135         .db %00000001                   ;       ██ ██
5136         .db %00000011                   ;      ████ █
5137         .db %00000111                   ;     ███ ███
5138         .db 19                          ;         █ █
5139         .db %01010000
5140         .db %01110000
5141         .db %11010000
5142         .db %10110000
5143         .db %10110000
5144         .db %11111000
5145         .db %11111110
5146         .db %01101100
5147         .db %11010111
5148         .db %10110101
5149         .db %11010111
5150         .db %01101100
5151         .db %11111110
5152         .db %11111000
5153         .db %10110000
5154         .db %10110000
5155         .db %11010000
5156         .db %01110000
5157         .db %01010000
5158 spr_boss09:
5159         .db 14,14                       ;.......:......7:
5160         .db %01100111                   ; ██  ████  ██
5161         .db %11001011                   ;██  █ ██ █  ██
5162         .db %10110000                   ;█ ██      ██ █
5163         .db %10101111                   ;█ █ ██████ █ █
5164         .db %01010000                   ; █ ██    ██ █
5165         .db %01010011                   ; █ █  ██   █ █
5166         .db %10100111                   ;█ █  ████ ██ █
5167         .db %10100111                   ;█ █  ████ ██ █
5168         .db %01010011                   ; █ █  ██   █ █
5169         .db %01010000                   ; █ ██    ██ █
5170         .db %10101111                   ;█ █ ██████ █ █
5171         .db %10110000                   ;█ ██      ██ █
5172         .db %11001001                   ;██  █ ██ █  ██
5173         .db %01100111                   ; ██  ████  ██
5174         .db 14
5175         .db %10011000
5176         .db %01001100
5177         .db %00110100
5178         .db %11010100
5179         .db %00101000
5180         .db %00010100
5181         .db %10110100
5182         .db %10110100
5183         .db %00010100
5184         .db %00101000
5185         .db %11010100
5186         .db %00110100
5187         .db %01001100
5188         .db %10011000
5189 spr_boss10:
5190         .db 16,19                       ;.......:.......:
5191         .db %01111011                   ; ████ ███
5192         .db %10000110                   ;█    ██ █████
5193         .db %00000011                   ;      ███ █
5194         .db %00111011                   ;  ███ ██   ███
5195         .db %00000111                   ;     ███ ███
5196         .db %00001100                   ;    ██  ███ █
5197         .db %00110111                   ;  ██ █████ █ ██
5198         .db %01111011                   ; ████ ██  █ ██ █
5199         .db %11100100                   ;███  █  ██ ██  █
5200         .db %00000001                   ;    ██████ ██  █
5201         .db %11100100                   ;███  █  ██ ██  █
5202         .db %01111011                   ; ████ ██  █ ██ █
5203         .db %00110111                   ;  ██ █████ █ ██
5204         .db %00001100                   ;    ██  ███ █
5205         .db %00000111                   ;     ███ ██
5206         .db %00111011                   ;  ███ ██   ███
5207         .db %00000011                   ;      ███ █
5208         .db %10000110                   ;█    ██ █████
5209         .db %01111011                   ; ████ ███
5210         .db 19
5211         .db %10000000
5212         .db %11111000
5213         .db %10100000
5214         .db %00011100
5215         .db %01110000
5216         .db %11101000
5217         .db %11010110
5218         .db %00101101
5219         .db %11011001
5220         .db %11011001
5221         .db %11011001
5222         .db %00101101
5223         .db %11010110
5224         .db %11101000
5225         .db %01100000
5226         .db %00011100
5227         .db %10100000
5228         .db %11111000
5229         .db %10000000
5230 ;spr_bossA2: ;in asm code
5231
5232 ;-----------------------------------------------------------------------------
5233 ;----------------------------- logo ------------------------------------------
5234 ;-----------------------------------------------------------------------------
5235
5236 logo_nemesis:
5237 #ifdef TI83
5238 .db %11111111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%00001011
5239 .db %01111111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%00011011
5240 .db %00111111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%00111011
5241 .db %00011111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%01111011
5242 .db %00000000,%00000000,%00000001,%00011110,%00010000,%00000000,%10000001,%00011110,%00010000,%000000001,%00000000,%00001000
5243 .db %00000000,%00000000,%00000011,%00011110,%00110000,%00000001,%10000011,%00011110,%00110000,%000000011,%00000000,%00011000
5244 .db %00000000,%00000000,%00000111,%00011110,%01110000,%00000011,%10000111,%00011110,%01110000,%000000111,%00000000,%00111001
5245 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011
5246 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011
5247 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011
5248 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011
5249 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000
5250 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000
5251 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000
5252 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000
5253 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011
5254 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011
5255 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011
5256 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011
5257 #endif
5258 #ifdef TI86
5259 .db %11111111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%00001011,%11111111,%11111111,%11111111,%11111110
5260 .db %01111111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%00011011,%11111111,%11111111,%11111111,%11111100
5261 .db %00111111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%00111011,%11111111,%11111111,%11111111,%11111000
5262 .db %00011111,%11111111,%11111111,%11111110,%11111111,%11110111,%11111111,%11111110,%11111111,%111101111,%11111111,%01111011,%11111111,%11111111,%11111111,%11110000
5263 .db %00000000,%00000000,%00000001,%00011110,%00010000,%00000000,%10000001,%00011110,%00010000,%000000001,%00000000,%00001000,%01000000,%00000000,%00000000,%00000000
5264 .db %00000000,%00000000,%00000011,%00011110,%00110000,%00000001,%10000011,%00011110,%00110000,%000000011,%00000000,%00011000,%11000000,%00000000,%00000000,%00000000
5265 .db %00000000,%00000000,%00000111,%00011110,%01110000,%00000011,%10000111,%00011110,%01110000,%000000111,%00000000,%00111001,%11000000,%00000000,%00000000,%00000000
5266 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011,%11111111,%11000000,%00000000,%00000000
5267 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011,%11111111,%11000000,%00000000,%00000000
5268 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011,%11111111,%11000000,%00000000,%00000000
5269 .db %00000000,%00000000,%00001111,%00011110,%11111111,%00000111,%10001111,%00011110,%11111111,%000001111,%11111111,%01111011,%11111111,%11000000,%00000000,%00000000
5270 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000,%00000011,%11000000,%00000000,%00000000
5271 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000,%00000011,%11000000,%00000000,%00000000
5272 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000,%00000011,%11000000,%00000000,%00000000
5273 .db %00000000,%00000000,%00001111,%00011110,%11110000,%00000111,%10001111,%00011110,%11110000,%000000000,%00001111,%01111000,%00000011,%11000000,%00000000,%00000000
5274 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011,%11111111,%11000000,%00000111,%11010001
5275 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011,%11111111,%11000000,%00000001,%00011011
5276 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011,%11111111,%11000000,%00000001,%00010101
5277 .db %00000000,%00000000,%00001111,%00011110,%11111111,%11110111,%10001111,%00011110,%11111111,%111101111,%11111111,%01111011,%11111111,%11000000,%00000001,%00010001
5278 #endif
5279
5280 ;----------------------------- end -------------------------------------------
5281
5282         .end
5283 .end
5284
5285
5286 ;-----------------------------------------------------------------------------
5287 ;-----------------------------------------------------------------------------
5288 ;-----------------------------------------------------------------------------
5289
5290 ; 0.99.99 -- 9.IX.00 -- size 6936
5291 ;
5292 ;       + you can have upto FOUR multiples! (~20 pixels apart)
5293 ;       * some optimizations: keycall, menu handling, port nops removed,
5294 ;          more SMC, fire handling, fast bullet handling, enemy movement
5295 ;       * better "backwards" enemies handling (and implemented in game)
5296 ;       # when enemy changed into a pickup, movement is set to vslow
5297 ;       * instead of turning into a pickup, enemies explode and a pickup
5298 ;          appears at the right side of the screen (moves left slowly)
5299 ;       # bullets do damage again (screenflash made damage become 0)
5300 ;       + when destroyed by bullets, the armor bar will show 0HP left
5301 ;       * all enemy bullets do the same damage in all levels
5302 ;       * you now appear at (*32*,30) because enemies can come from left
5303 ;       * improved bullet handling (faster, smaller, etc.)
5304 ;       + multiples are animated like real Nemesis (grow-shrink-grow-shrink>)
5305 ;       # fixed a bug that didn't select multiples when you were moving
5306 ;       # enemy collision screwed up invert and some other weird stuff
5307 ;       + in pause screen change contrast with up/down and B/W mode with F1
5308 ;       + lasers can have different durations (beams last longer)
5309 ;       * some sign-flag checkings replaced by carry-flag (thus reducing size)
5310 ;       # slow enemies (including pickups) didn't always appear (just 25-50%)
5311 ;       + enemies can fire different kinds of bullets: aiming, double, triple
5312 ;       * maximum number of bullets increased (48 for enemies, 128 for you)
5313 ;       * beamweapon can be selected when you got laser (like vice versa)
5314 ;       * selecting laser removes tailbeam or up-double
5315 ;       # tail beam/up-double correctly centered
5316 ;       # disappearing bullets (when enemies fired multiple bullets) fixed
5317 ;       + bullets and lasers both upgradable upto level 9
5318 ;       # fixed end story (_vputs didn't recognize 0-end when "'" in string)
5319 ;       # stars couldn't be altered anymore since recent levelformat changes
5320 ;       * maximum different enemies increased from 28 to 63
5321 ;       * pickup sprite altered, small changes to some enemies
5322 ;       + new moves implemented: 75% speed and lure-while-moving
5323 ;       # fixed the enemy aiming bullets procedure
5324 ;       * enemies fire their bullets centered too! (even the large bosses)
5325 ;       * you may NOT have any multiples together with beams, just lasers
5326 ;       + added new enemy guns: quad- and 6x-fire!!
5327 ;       * sprite table length increased to 768 bytes (stored DIV3)
5328 ;       + ships 3/4 select hardcore mode: score and damage are doubled
5329 ;       + first icon not only increases armor, but also activates shield for
5330 ;          some time (shield halves damage and absorbs bullets in normal mode)
5331 ;       + ship selection screen also shows ship specs (hardcore/tailbeam/etc)
5332 ;       * shield looks different for each ship
5333 ;       * hiscore/savegame procedure optimized (several bytes smaller)
5334 ;       + B<>W mode setting will be stored
5335 ;       * enemy sprite pointers stored as words (thus increasing sprite table
5336 ;          length from 768B to 65kB, and increasing sprite calculation speed)
5337 ;       * hardcore mode does _more_ than doubled damage (bulletsdamage +1)
5338 ;       * 10 bytes off by optimizing main menu a little
5339 ;       * and optimizations to hiscore name handling saved another 17 bytes!
5340 ;       * score increased by 1 per placed enemy, instead of time (otherwise
5341 ;          you could just evade bosses for a long time for very high score)
5342 ;       * findpixel optimized (or rather un-unoptimized: restored to original)
5343 ;       # ground fixed again (and optimized for tunnel only)
5344 ;       # prevents exploding more than once (not dieing while inside ground)
5345 ;       * some unneccessary pushes removed
5346 ;       + final boss also fires moving mines (just up/down-enemies)
5347 ;       * on collision less damage to enemy, more to you (bosses too simple)
5348 ;       * normal pickups will increase armor and shield directly (no [alpha])
5349 ;       + a large pickup'll appear at the end of a level which will select
5350 ;          your next upgrade: beamweapon, laser, multiple/tailbeam/up-double
5351 ;       + a small explosion is displayed when enemy's hit but not destroyed
5352 ;       # _all_ multiples appear at your position at start of level
5353 ;       # bug in selecting multiples fixed (recent bug)
5354 ;       + getting passed 3rd upgrade (4 pickups) increases score by 250!
5355 ;       - second icon integrated in 5th, first two icons removed (unused now)
5356 ;       * the armor bar is now 5 pixels in height; very visible
5357 ;       # if selecting upgrade or starting level, charge bar wasn't displayed
5358 ;
5359 ; 1.00.C21 -- 21.XII.00 -- size 6797
5360 ;
5361 ;       * armor-bar background, empty upgrades sprites changed
5362 ;       + shows sprite when laser hits an enemy (his "shield"?)
5363 ;       + exit-key also quits out of ship selection screen
5364 ;       # fixed direct-quit on death bug (bug since recent optimization)
5365 ;       * armor-bar background changed (more elegant and smaller code)
5366 ;       # "flash" when end-boss spawns mine fixed
5367 ;       + enemy's y start position can be specified per enemy
5368 ;       + when bullets selected, upgrade icons won't appear half the time
5369 ;       # remainder pixels in armor bar (appeared after heavy damage) removed
5370 ;       + your ship's explosion is now also 8 frames (half enemy expl. speed)
5371 ;       + does NOT display Done after running in TI-OS! (anti-teacher ;)
5372 ;       * storyline completed (probably the crappiest story ever!)
5373 ;       # only first byte of ship's sprite altered; now loads whole word
5374 ;       - tail beam removed (up double only); odd ships now contain laser
5375 ;       # fixed laserbeam display when firing at right edge
5376 ;       # star relocation altered to work correctly w/ new screen location
5377 ;       # halfluring wasn't 50% (more like 75%) since random enemy spawning
5378 ;       * restored multiples for bullets (since it's unlikely you'll select 1)
5379 ;       # fixed mem overlapping causing "weird stuff" when moving multiples
5380 ;       # bullets fired below screen bottom are moved up onto screen
5381 ;       + SOURCE ALSO TI-83 COMPATIBLE (still few bugs like hiscore, bullets)
5382 ;       # upgrading beam weapon removed multiples
5383 ;       # clipping at left side wrong in TI-83 version fixed
5384 ;
5385 ;
5386 ;        + added        - removed       * changed       # bug fixed
5387
5388 ;bullet handling: (255/enemy)+419+putsprite cycles per bullet