; Jonah Cohen : helped writing worm
; Files : wormy.txt (9283) : 12345678901234567890123456789012
; wormy.z80 (100k) : 515ad14b922572bdc8a96e780b8b24ca
-; wormy.86g (12k) : efef32a8c541b4585087f55deb31f51d
+; wormy.86g (8867) : efef32a8c541b4585087f55deb31f51d
;_______________________________________________________________________________
;--- notes ---------------------------------------------------------------------
; crazy optimizations and weird coding, it may be harder to
; understand than the average blob of code. This is probably _not_
; the best source to learn z80 from. w00t the Shyer Way (tm).
-; * Email me. If you've got suggestions, tell me.
+; * Email me. If you've got suggestions|patches|questions: tell me.
; * Don't scroll down if you get scared easily.
;--- index ---------------------------------------------------------------------
-;-* TO_DO
-; | future features
-;--* #INCLUDE
-;---* STORAGE
-; | permanent
-; | temporary
-; | layout
-;----* PROG_START
-; | search levels
-;-----* LEV_SELECT
-;------* MORE_INIT
-; | trig tables
-;-------* MAIN_MENU
-; | draw menu
-; | options menu
-; | main menu
-; | display current settings
-; | handle menukeys
-; | change name
-;--------* MISC_PROCS
-;---------* START_GAME
-; | link
-; | client
-; | set/send worms
-; | host
-; | load game
-; | draw level
-; | prepare
-;----------* GAME_LOOP
-;-----------* KEYS
-; | pause menu
-;------------* GAME_OVER
-; | who won?
-; | display worms
-; | quit
-;-------------* WORM_STUFF
-;--------------* WORM_ALIVE
-; | move worm
-; | draw worm
-;---------------* BOUNCYBALL
-;----------------* WORMY_HIT
-; | multifood
-; | ctf
-; | main
-; | foodmatch|SP
-; | take pea
-; | misc
-;-----------------* PROCS
-;------------------* SCORE
-;-------------------* DISPLAY
-;--------------------* DRAW
-; | pixel
-; | findpixel
-; | objects
-; | circle
-; | box
-; | fatline
-; | line
-;---------------------* LINK!
-; | multiple bytes
-; | foo
-; | send
-; | recv
-; | common
-;----------------------* INT_LEVELS
-;-----------------------* DATA
-; | graphics
-; | menus
-; | text
-; | foo
-; | game settings
-;------------------------* THAT'S_ALL
+; * TO_DO : future features
+; * #INCLUDE
+; * STORAGE : permanent; temporary; layout
+; * PROG_START : search levels
+; * LEV_SELECT
+; * MORE_INIT : trig tables
+; * MAIN_MENU : draw menu; options menu; main menu; display
+; current settings; handle menukeys; change name
+; * MISC_PROCS
+; * START_GAME : link; client; set/send worms; host; load game;
+; draw level; prepare
+; * GAME_LOOP
+; * KEYS : pause menu
+; * GAME_OVER : who won?; display worms; quit
+; * WORM_STUFF
+; * WORM_ALIVE : move worm; draw worm
+; * BOUNCYBALL
+; * WORMY_HIT : multifood; ctf; main; foodmatch|SP; take pea;
+; misc
+; * PROCS
+; * SCORE
+; * DISPLAY
+; * DRAW : pixel; findpixel; objects; circle; box;
+; fatline; line
+; * LINK! : multiple bytes; foo; send; recv; common
+; * INT_LEVELS
+; * DATA : graphics; menus; text; foo; game settings
+; * THAT'S_ALL
;_______________________________________________________________________________
; _______ _____ ______ _____
; | |_____| ____ |_____/ |_____|
;_______________________________________________________________________________
-; 98% = CURRENT
+; 98% = PREVIOUS
; X [119] ED: new 53 file format with support for 128 objects instead of 32
; X [119] LVL: episode #4: 10 hard sp levels (ordered XO-XO-XO-X)
; X [120] fixed greymask (and it now ands instead of ors)
; X [227] no more points in race for dieing on the second half
; X [227] no score decrease for dieing in race (no longer needed, see above)
; 99% = CURRENT
+; X [34] two more jp to jr
+; X [34] freeze when no space left to place pea (break after 10k tries)
+; X [34] wow another bit of code 'reniced' (easter egg or something :)
+; X [34] highly improved randomizer (now _really_ with values >127)
; 1% * LINK: >Somehow do a lot of testing with 2 calcs< *sigh*
; * LVL: episode #5: 10 easy sp levels (do i _have_ to?)
; * LVL: Eric's Yumworms (ep#5?)
randompos:
ld b,a
Random: ;(2..b+2)
- ld a,r
+ ld a,r ;0..127
+ scf ;not just even values:
+ rla ;6543210C
Seed =$+1
add a,0
ld (Seed),a
ret
NewPea:
+ ld de,$293A ;counter :)
+newpealoop:
+ dec de
+ ld a,d
+ or e
+ jp z,Exit ;break after 10554 tries to prevent freeze when field filled
ld a,(FieldWidth)
- add a,127-4
+ add a,126
cal randompos
ld h,a
ld a,(FieldHeight)
- add a,56-4
+ add a,55
cal randompos
ld l,a
+ psh de
cal CheckPea
- jr nz,NewPea
+ pop de ;counter
+ jr nz,newpealoop
cal sendnewpeaoverlink
ld (PeaY),hl
DrawPea: ;hl=(PeaY)
out (1),a ;select keys
in a,(1) ;input
bit 6,a ;exit key
- jp z,Exit ;break!
+ jr z,linkerr ;break!
linkfine:
in a,(7)
and %11