worm 0.84.0327: external levels (wormlvl.86s)
authorMischa Poslawsky <wormy@shiar.org>
Mon, 27 Mar 2000 21:11:16 +0000 (23:11 +0200)
committerMischa Poslawsky <wormy@shiar.org>
Sun, 22 Feb 2009 15:13:37 +0000 (16:13 +0100)
Try to read levels from calculator string 'wormlvl'.  Its source is
documented and can be modified to customise levels.

worm.z80
wormlvl.z80 [new file with mode: 0644]

index 45088ab988fd76eb7c3f7056afcbcc6fff1e8e8a..d50545fe7c0cbfa70a623cb899249a25c3c6a54a 100644 (file)
--- a/worm.z80
+++ b/worm.z80
@@ -48,6 +48,8 @@ _mov9b     = $4283 ;9x ld (de),(hl)
 _ldHLind   = $4010 ;ld hl,(hl)
 _swapt_    = $45F3 ;ex_ahl_bde
 
 _ldHLind   = $4010 ;ld hl,(hl)
 _swapt_    = $45F3 ;ex_ahl_bde
 
+leveldata  = $EA00 ;size<$400
+
 ;-----------------------------
 ;------- program start -------
 ;-----------------------------
 ;-----------------------------
 ;------- program start -------
 ;-----------------------------
@@ -72,13 +74,50 @@ WormIcon:
   .db %11101111,%00001111
   .db %11000011,%10000000
 
   .db %11101111,%00001111
   .db %11000011,%10000000
 
+levelfile:
+  .db 7,"wormlvl"
+
 Start:
   ld  (SpSave),sp
   call _runindicoff
   call _flushallmenus
   call _clrLCD
 Start:
   ld  (SpSave),sp
   call _runindicoff
   call _flushallmenus
   call _clrLCD
-  res 2,(iy+13) ;appAutoScroll
 
 
+  ld  hl,levelfile-1
+  rst 20h ;_ABS_MOV10TOOP1
+  rst 10h ;_FINDSYM
+  ret c ;not found
+  ex  de,hl
+  ld  a,b ;call _ex_ahl_bde
+  call _SET_ABS_SRC_ADDR
+
+  xor a
+  ld  hl,leveldata ;datalevels
+  call _SET_ABS_DEST_ADDR
+ xor a
+  ld  hl,2
+  call _SET_MM_NUM_BYTES
+  call _mm_ldir
+
+  xor a
+  ld  hl,datalevels
+  call _SET_ABS_DEST_ADDR
+ xor a
+  ld  hl,16
+  call _SET_MM_NUM_BYTES
+  call _mm_ldir
+
+ xor a
+  ld  hl,leveldata
+  call _SET_ABS_DEST_ADDR
+ xor a
+  ld  hl,400
+  call _SET_MM_NUM_BYTES
+  call _mm_ldir
+
+ call _RAM_PAGE_1
+
+  res 2,(iy+13) ;appAutoScroll
   ld  a,r
   ld  (Seed),a
 
   ld  a,r
   ld  (Seed),a
 
@@ -249,16 +288,18 @@ notup:
 ;-----------------------------
 
 LetsGetThisPartyOn:
 ;-----------------------------
 
 LetsGetThisPartyOn:
-  ld  hl,Gametype
-  ld  a,(hl)
-  add a,a
-  add a,(hl)
+  ld  hl,gamesdata
+  ld  a,(Gametype)
   ld  e,a
   ld  d,0
   ld  e,a
   ld  d,0
-  ld  hl,gamesdata
   add hl,de
   add hl,de
-
   ld  a,(hl)
   ld  a,(hl)
+  ld  (gameCar),a
+
+  add hl,de
+  ld  e,8 ;=de
+  add hl,de
+
   ld  d,a ;push af
   and _datasingl
   jr  z,notsingle
   ld  d,a ;push af
   and _datasingl
   jr  z,notsingle
@@ -271,8 +312,7 @@ LetsGetThisPartyOn:
   ld  (worm1+lives),a
 notsingle:
   ld  a,d
   ld  (worm1+lives),a
 notsingle:
   ld  a,d
-  ld  (gameCar),a
-  push af
+  push af ;&&&b?
 
   and _datascore
   ld  de,$FF64 ;virt.infinate
 
   and _datascore
   ld  de,$FF64 ;virt.infinate
@@ -281,8 +321,7 @@ notsingle:
 setscorelimit:
   ld  (scorelimit),de
 
 setscorelimit:
   ld  (scorelimit),de
 
-  inc hl
-  call _ldHLind
+  call _ldHLind ;ld hl,(hl)
   pop af
   push hl
   and _datalink
   pop af
   push hl
   and _datalink
@@ -316,7 +355,6 @@ client:
 multiplayer:
   ld  a,2
   ld  (nrworms),a
 multiplayer:
   ld  a,2
   ld  (nrworms),a
-  ld  de,LevelsDM
 
 ;-----------------------------
 ;--------- game over ---------
 
 ;-----------------------------
 ;--------- game over ---------
@@ -354,10 +392,9 @@ GameOver:
   ld  de,worm4+lives
   call _MOV5B
   call _mov9b
   ld  de,worm4+lives
   call _MOV5B
   call _mov9b
-  pop de
+  pop hl
 
 StartLevel:
 
 StartLevel:
-  ex  de,hl
   ld  de,Left
   ldi
   ld  de,Speed
   ld  de,Left
   ldi
   ld  de,Speed
@@ -1033,7 +1070,7 @@ PeaX =$-1
   inc (hl)
   pop hl                         ; << call
   pop hl                         ; << call
   inc (hl)
   pop hl                         ; << call
   pop hl                         ; << call
-  pop de                         ; << levelp new
+  pop hl                         ; << levelp new
   cp  NUM_LEVELS
   jp  z,Exit
   ld  a,(gameCar)
   cp  NUM_LEVELS
   jp  z,Exit
   ld  a,(gameCar)
@@ -1982,151 +2019,19 @@ CheckLink:
 ;---------- levels -----------
 ;-----------------------------
 
 ;---------- levels -----------
 ;-----------------------------
 
-LevelsDM:
-  .db 8,5,15,0
-  .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
-  .db 128,57
-  .db 0,0
-
-LevelsDM2:
-  .db 8,5,31,0
-  .db $40,28,2,$C0,28,125, $00,2,63,$80,54,63
-  .db 128,57
-  .db 0
-  .db 4             ;4 boxes
-  .db 4,19,16,14    ;xsize,ysize,xpos,ypos
-  .db 4,19,80,14
-  .db 4,19,16,34
-  .db 4,19,80,34
-
-LevelsL:
-  .db 8,0,15,0
-  .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
-  .db 228,157
-  .db 0,0
-
-LevelsR:
-  .db 8,2,10,0
-  .db $40,3,2,$40,6,2, $40,9,2,$40,12,2
-  .db 128,57
-  .db 0
-  .db 1
-  .db 8,29,32,20
-
-LevelsH:
-  .db 8,7,17,0
-#ifdef 0
-huntersize = 31
-#endif
-  .db $40,28,2,$C0,28,125, $00,2,63,$80,54,63
-  .db 128,57
-  .db 0
-  .db 4
-  .db 4,19,16,14
-  .db 4,19,80,14
-  .db 4,19,16,34
-  .db 4,19,80,34
-
-NUM_LEVELS = 10
-
-LevelsS:
+NUM_LEVELS = 1
 
 
+LevelDef:
   .db 5,4,15,0      ;peas,speed,begin_size,balls
   .db 0,2,63        ;start d, y, x
   .db 128,57        ;field width (128-255), height (57-255)
   .db 0,0           ;no additional lines, boxes
 
   .db 5,4,15,0      ;peas,speed,begin_size,balls
   .db 0,2,63        ;start d, y, x
   .db 128,57        ;field width (128-255), height (57-255)
   .db 0,0           ;no additional lines, boxes
 
-  .db 8,4,15,0
-  .db $40,14,2
-  .db 128,57
-  .db 1
-  .db 28,28,100,28  ;line coords: x1,y1,x2,y2
-  .db 0
-
-  .db 9,4,15,0
-  .db $40,8,2
+LevelDefM:
+  .db 8,0,15,0
+  .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
   .db 128,57
   .db 128,57
-  .db 2
-  .db 28,14,100,14
-  .db 28,41,100,41
-  .db 0
-
-  .db 9,3,15,0
-  .db $40,8,2
-  .db 128,80
-  .db 2
-  .db 64,14,64,66
-  .db 20,40,108,40
-  .db 0
-
-  .db 10,3,15,0
-  .db 2,8,$40
-  .db 128,90
-  .db 3
-  .db 18,20,18,70
-  .db 110,20,110,70
-  .db 18,45,110,45
-  .db 0
-
- .db 4,3,10,1 \ .dw $20F
- .db 0,2,63
- .db 128,57
- .db 2
- .db 28,14,100,41
- .db 28,41,100,14
- .db 0
-
-  .db 7,3,15,0
-  .db 64,4,0
-  .db 128,86
-  .db 6
-  .db 34,13,56,35
-  .db 34,71,56,49
-  .db 72,35,94,13
-  .db 72,49,94,71
-  .db 16,20,16,64
-  .db 110,20,110,64
-  .db 0
-
-  .db 9,3,15,0
-  .db $40,4,10
-  .db 128,82
-  .db 3
-  .db 0,20,74,20
-  .db 54,40,128,40
-  .db 0,60,74,60
-  .db 0
-
-  .db 12,3,15,0
-  .db $40,4,0
-  .db 128,90
-  .db 6
-  .db 20,16,54,16
-  .db 74,16,110,16
-  .db 20,16,20,72
-  .db 110,16,110,72
-  .db 20,72,54,72
-  .db 74,72,110,72
-  .db 0
-
-  .db 8,2,15,0
-  .db $C0,72,48
-  .db 128,128
-  .db 13
-  .db 34,56,56,34
-  .db 34,72,56,94
-  .db 72,34,94,56
-  .db 72,94,94,72
-  .db 46,64,80,64
-  .db 22,11,22,33
-  .db 11,22,33,22
-  .db 22,95,22,117
-  .db 11,106,33,106
-  .db 103,11,103,33
-  .db 91,22,115,22
-  .db 103,95,103,117
-  .db 91,106,115,106
-  .db 0
+  .db 0,0
 
 
 ;-----------------------------
 
 
 ;-----------------------------
@@ -2184,24 +2089,18 @@ _datalaps  = %01000000 ;give lap score
 _datascore = %10000000 ;score>=100 limit
 
 datasingle: .db %00011110
 _datascore = %10000000 ;score>=100 limit
 
 datasingle: .db %00011110
-            .dw LevelsS
 datapeas:   .db %00011010
 datapeas:   .db %00011010
-            .dw LevelsS
 datadeathm: .db %00000010
 datadeathm: .db %00000010
-            .dw LevelsDM2
 datafoodm:  .db %10010000
 datafoodm:  .db %10010000
-            .dw LevelsDM
 datalinkm:  .db %00000011
 datalinkm:  .db %00000011
-            .dw LevelsL
 datahuntin: .db %10100000
 datahuntin: .db %10100000
-            .dw LevelsH
 datarace:   .db %11000000
 datarace:   .db %11000000
-            .dw LevelsR
-datactf:    .db %00000000
-            .dw LevelsDM
-datadomin:  .db %00000000
-            .dw LevelsDM
-
+datactf:    .db %00000000 ;==(8 modes)
+;datadomin:  .db %00000000
+datalevels: .dw LevelDef, LevelDef
+            .dw LevelDefM,LevelDefM
+            .dw LevelDefM,LevelDefM
+            .dw LevelDefM,LevelDefM
 
 resbit  = 2             ;and%11111011
 worm1set:  .dw $B000,$B000 ;%10110000
 
 resbit  = 2             ;and%11111011
 worm1set:  .dw $B000,$B000 ;%10110000
diff --git a/wormlvl.z80 b/wormlvl.z80
new file mode 100644 (file)
index 0000000..00c4268
--- /dev/null
@@ -0,0 +1,159 @@
+.org $EA00-16
+
+.dw  single,peaworm,deathmatch,foodmatch
+.dw  linkmatch,hunting,race,ctf
+
+;-----------------------------
+;---------- levels -----------
+;-----------------------------
+
+NUM_LEVELS = 10
+
+single:
+peaworm:
+
+  .db 5,4,15,0      ;peas,speed,begin_size,balls
+  .db 0,2,63        ;start d, y, x
+  .db 128,57        ;field width (128-255), height (57-255)
+  .db 0,0           ;no additional lines, boxes
+
+  .db 8,4,15,0
+  .db $40,14,2
+  .db 128,57
+  .db 1
+  .db 28,28,100,28  ;line coords: x1,y1,x2,y2
+  .db 0
+
+  .db 9,4,15,0
+  .db $40,8,2
+  .db 128,57
+  .db 2
+  .db 28,14,100,14
+  .db 28,41,100,41
+  .db 0
+
+  .db 9,3,15,0
+  .db $40,8,2
+  .db 128,80
+  .db 2
+  .db 64,14,64,66
+  .db 20,40,108,40
+  .db 0
+
+  .db 10,3,15,0
+  .db 2,8,$40
+  .db 128,90
+  .db 3
+  .db 18,20,18,70
+  .db 110,20,110,70
+  .db 18,45,110,45
+  .db 0
+
+ .db 4,3,10,1 \ .dw $20F
+ .db 0,2,63
+ .db 128,57
+ .db 2
+ .db 28,14,100,41
+ .db 28,41,100,14
+ .db 0
+
+  .db 7,3,15,0
+  .db 64,4,0
+  .db 128,86
+  .db 6
+  .db 34,13,56,35
+  .db 34,71,56,49
+  .db 72,35,94,13
+  .db 72,49,94,71
+  .db 16,20,16,64
+  .db 110,20,110,64
+  .db 0
+
+  .db 9,3,15,0
+  .db $40,4,10
+  .db 128,82
+  .db 3
+  .db 0,20,74,20
+  .db 54,40,128,40
+  .db 0,60,74,60
+  .db 0
+
+  .db 12,3,15,0
+  .db $40,4,0
+  .db 128,90
+  .db 6
+  .db 20,16,54,16
+  .db 74,16,110,16
+  .db 20,16,20,72
+  .db 110,16,110,72
+  .db 20,72,54,72
+  .db 74,72,110,72
+  .db 0
+
+  .db 8,2,15,0
+  .db $C0,72,48
+  .db 128,128
+  .db 13
+  .db 34,56,56,34
+  .db 34,72,56,94
+  .db 72,34,94,56
+  .db 72,94,94,72
+  .db 46,64,80,64
+  .db 22,11,22,33
+  .db 11,22,33,22
+  .db 22,95,22,117
+  .db 11,106,33,106
+  .db 103,11,103,33
+  .db 91,22,115,22
+  .db 103,95,103,117
+  .db 91,106,115,106
+  .db 0
+
+deathmatch:
+  .db 8,5,31,0
+  .db $40,28,2,$C0,28,125, $00,2,63,$80,54,63
+  .db 128,57
+  .db 0
+  .db 4             ;4 boxes
+  .db 4,19,16,14    ;xsize,ysize,xpos,ypos
+  .db 4,19,80,14
+  .db 4,19,16,34
+  .db 4,19,80,34
+
+foodmatch:
+ctf:
+  .db 8,5,15,0
+  .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
+  .db 128,57
+  .db 0,0
+
+linkmatch:
+  .db 8,0,15,0
+  .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
+  .db 228,157
+  .db 0,0
+
+hunting:
+  .db 8,7,17,0
+#ifdef 0
+huntersize = 31
+#endif
+  .db $40,28,2,$C0,28,125, $00,2,63,$80,54,63
+  .db 128,57
+  .db 0
+  .db 4
+  .db 4,19,16,14
+  .db 4,19,80,14
+  .db 4,19,16,34
+  .db 4,19,80,34
+
+race:
+  .db 8,2,10,0
+  .db $40,3,2,$40,6,2, $40,9,2,$40,12,2
+  .db 128,57
+  .db 0
+  .db 1
+  .db 8,29,32,20
+
+  .end
+.end
\ No newline at end of file