Map designing, that is where I would've cracked out some Lego bricks and randomly placing them onto a huge grey baseboard, but you designed a map maker and made a bloody good job of it too! Glad that you're making progress on finding ways of getting the maps to behave better.
Spent an evening screen grabbing a whole lot of maps made by your map maker, numbering them up with 1s and 0s, and typing in the data and this is the result so far...
It contains 25 random maps made by your program, converted into 11 bytes per map, decodes, random flip a bit to mirror it, sort the corners and ends out, bung in the ghost door, do a simple print using the rom routine.
700 bytes with udgs.
Just need to byte align the map to a 256 boundary and add the dots.
Code: Select all
Screen Equ 16384
ScreenAttribs Equ 22528
Org 32768
Start
LD A,2 ; always print to the top area
CALL 05633
LD HL,UDGs
LD (23675),HL
LD IX,Map0001 ; put map address into IX and save a headache
pickagain LD A,R
CP 25
JR NC,pickagain
LD B,A ;1
ADD A ;2
ADD A ;4
ADD B ;5
ADD A ;10
ADD B ;11
LD C,A
LD B,0
ADD IX,BC
mapaa
CALL UnpackMap
; all unpacked,
CALL FlipMap ; now flip the map at a toss of a bit
CALL PutCornersIn ; and place the ghost door
PrintTheMapToTheScreen ;
; Print AT 0,0
LD A,22 ;Print AT control
RST 16
XOR A ; 0
RST 16
RST 16
;
LD HL,Map ; place of the unpacked map data
LD BC,768-64 ; amount of bytes to process
printloop LD A,(HL) ; read byte
ADD 144 ; add the UDG offset
RST 16 ; print the UDG to the scree
INC HL ; shuffle along the map data
DEC BC ; decrease the counter
LD A,B ;
OR C ; does B and C match zero?
JR NZ,printloop ; JR if no
RET
;---------------------------------------------------------------
FlipMap LD A,R
BIT 0,A
RET Z
LD DE,Map+32
LD HL,Map+(20*32)
LD B,11
mainfliploop PUSH BC
LD B,32
fliponeline LD C,(HL)
LD A,(DE)
LD (HL),A
LD A,C
LD (DE),A
INC DE
INC HL
DJNZ fliponeline
LD BC,65536-64
ADD HL,BC
POP BC
DJNZ mainfliploop
RET
;---------------------------------------------------------------
PutCornersIn LD IX,Map
LD B,8 ; Counter for rows
Cornerloop PUSH BC ; store counter
LD B,11 ; Counter for columns
Cornerbitsloop XOR A ; set A to zero
LD D,A ; D to zero ; part of the jump offset, saves a byte
LD C,A ; C to zero for totals
CheckUP CP (IX-32) ; is the square above empty
JR Z,Exitup ; yes, do JR
SET 0,C ; no, add 1
Exitup
CheckRIGHT CP (IX+1) ; is square to the right empty
JR Z,Exitright ; yes, do JR
SET 1,C ; no, add 2
Exitright
CheckDOWN CP (IX+32) ; is square below empty
JR Z,Exitdown ; yes, do JR
SET 2,C ; no, add 4
Exitdown
CheckLEFT CP (IX-1) ; is squre to the left empty
JR Z,Exitleft ; yes, do JR
SET 3,C ; no, add 8
Exitleft
LD (IX+0),C ; put C into the empty square
LD E,3 ; offset jump
ADD IX,DE ; move along
DJNZ Cornerbitsloop ; loop
LD E,63 ; offset jump to move down 2 lines
ADD IX,DE ; move
POP BC ; recall counter
DJNZ Cornerloop ; loop
PlaceTheGhostDoor
LD HL,GhostDoorData
LD DE,Map+(9*32)+13
LD BC,5
LDIR
RET
GhostDoorData DEFB 8,0,0,0,2
;---------------------------------------------------------------
UnpackMap LD HL,Map+32 ; unpack data here
LD DE,30 ; offset to jump to the other side of the screen
LD B,5 ; repeat counter
mainloop PUSH BC ; store repeat counter
CALL ColARoutine ;
LD BC,64833 ;65536-31-768+96 ; move up one line and one place right
ADD HL,BC
DEC DE ; decrease the jump value to the other side
DEC DE
DEC DE
DEC DE
INC IX ; next place for the map data
LD C,(IX+0) ; read the byte
LD B,8 ; counter
ColBloop PUSH BC ; store count and C
LD A,10 ; wall OK
BIT 0,C ; check the bit
JR NZ,ColBplacecolour ;
XOR A ; not wanted value
ColBplacecolour LD (HL),A ; onto screen
PUSH HL ; store for a moment
INC HL ; move along
LD (HL),A ; onto screen
ADD HL,DE ; to the opposite side
LD (HL),A ; onto the screen
INC HL ; move along
LD (HL),A ; onto the screen
POP HL ; recall place
LD BC,96 ; down 3 lines
ADD HL,BC
POP BC ; recall count and C
RR C ; RoR C
DJNZ ColBloop
LD BC,34-768 ; move one line down and two places
ADD HL,BC
DEC DE ; decrease the jump value
DEC DE
INC IX ; next place in the map data
POP BC ; recall the counter
DJNZ mainloop ; loop until done
; this is here so that the middle column is completed
ColARoutine LD C,(IX+0) ; read from the map data
LD B,7 ; counter
ColAloop PUSH BC ; store count and C
LD A,5 ; wall OK
BIT 0,C ; check the bit
JR NZ,ColAplacecolour ;
XOR A ; not wanted value ; wipes old data too!
ColAplacecolour LD (HL),A ; onto screen
LD BC,32 ; down a line
ADD HL,BC
LD (HL),A ; onto screen
PUSH HL ; store for a moment
ADD HL,DE ; jump to the other side of the screen
LD (HL),A ; onto the screen
SBC HL,BC ; up one line
LD (HL),A ; onto the screen
POP HL ; recall the place
ADD HL,BC ; down two lines
ADD HL,BC
POP BC ; recall count and C
RR C ; RoR C
DJNZ ColAloop
RET ;
DEFW 255,255
;---------------------------------------------------------------
Map0001
DEFB %01111011; A
DEFB %10101101; B
DEFB %00000000; C
DEFB %11010011; D
DEFB %00101000; E
DEFB %10110111; F
DEFB %00000100; G
DEFB %11000101; H
DEFB %00001000; I
DEFB %10111011; J
DEFB %01000010; K
Map0002
DEFB %01111011 ; A
DEFB %10101101 ; B
DEFB %00000000 ; C
DEFB %11010011 ; D
DEFB %00011010 ; E
DEFB %11000001 ; F
DEFB %00010101 ; G
DEFB %10000101 ; H
DEFB %00001000 ; I
DEFB %11111011 ; J
DEFB %00000010 ; K
Map0003
DEFB %01111110 ; A
DEFB %10001011 ; B
DEFB %00100000 ; C
DEFB %11010101 ; D
DEFB %00010100 ; E
DEFB %10010011 ; F
DEFB %00100100 ; G
DEFB %11000111 ; H
DEFB %00001000 ; I
DEFB %10111001 ; J
DEFB %00100011 ; K
Map0004
DEFB %01101111 ; A
DEFB %10110001 ; B
DEFB %00000100 ; C
DEFB %11001011 ; D
DEFB %00010000 ; E
DEFB %10011111 ; F
DEFB %00100000 ; G
DEFB %10000101 ; H
DEFB %00101000 ; I
DEFB %10111011 ; J
DEFB %01000010 ; K
Map0005
DEFB %01101111 ; A
DEFB %10110101 ; B
DEFB %00000000 ; C
DEFB %11001011 ; D
DEFB %00101010 ; E
DEFB %10001101 ; F
DEFB %01010000 ; G
DEFB %10000011 ; H
DEFB %00001010 ; I
DEFB %11111001 ; J
DEFB %00000011 ; K
Map0006
DEFB %01111110 ; A
DEFB %10001011 ; B
DEFB %00100000 ; C
DEFB %11010101 ; D
DEFB %00011010 ; E
DEFB %10010011 ; F
DEFB %00100100 ; G
DEFB %11000001 ; H
DEFB %00001010 ; I
DEFB %10111001 ; J
DEFB %00100011 ; K
Map0007
DEFB %01111110 ; A
DEFB %10100011 ; B
DEFB %00000100 ; C
DEFB %11011001 ; D
DEFB %00010010 ; E
DEFB %10000001 ; F
DEFB %00110101 ; G
DEFB %10000101 ; H
DEFB %00101000 ; I
DEFB %10111011 ; J
DEFB %01000010 ; K
Map0008
DEFB %01111111 ; A
DEFB %10001001 ; B
DEFB %00100010 ; C
DEFB %10110011 ; D
DEFB %00001000 ; E
DEFB %11100111 ; F
DEFB %00001000 ; G
DEFB %11000101 ; H
DEFB %00001000 ; I
DEFB %10111011 ; J
DEFB %01000010 ; K
Map0009
DEFB %01111111 ; A
DEFB %10001001 ; B
DEFB %00010010 ; C
DEFB %11010001 ; D
DEFB %00000010 ; E
DEFB %11111001 ; F
DEFB %00000001 ; G
DEFB %10000101 ; H
DEFB %01001000 ; I
DEFB %10111011 ; J
DEFB %00100010 ; K
Map0010
DEFB %01110111 ; A
DEFB %10011001 ; B
DEFB %00100010 ; C
DEFB %10100011 ; D
DEFB %00001000 ; E
DEFB %11010111 ; F
DEFB %00100100 ; G
DEFB %11000001 ; H
DEFB %00001010 ; I
DEFB %10111001 ; J
DEFB %01000011 ; K
Map0011
DEFB %01111110 ; A
DEFB %10100011 ; B
DEFB %00000100 ; C
DEFB %11010001 ; D
DEFB %00000010 ; E
DEFB %10101001 ; F
DEFB %00110101 ; G
DEFB %10000101 ; H
DEFB %00101000 ; I
DEFB %10111011 ; J
DEFB %01000010 ; K
Map0012
DEFB %01111111 ; A
DEFB %10100101 ; B
DEFB %00001000 ; C
DEFB %11001011 ; D
DEFB %00100010 ; E
DEFB %10110011 ; F
DEFB %00001000 ; G
DEFB %11000101 ; H
DEFB %00001010 ; I
DEFB %10111001 ; J
DEFB %01000011 ; K
Map0013
DEFB %01111111 ; A
DEFB %10001001 ; B
DEFB %00100010 ; C
DEFB %11010011 ; D
DEFB %00010100 ; E
DEFB %10100101 ; F
DEFB %00001001 ; G
DEFB %11000101 ; H
DEFB %00001000 ; I
DEFB %10111011 ; J
DEFB %01000010 ; K
Map0014
DEFB %01111011 ; A
DEFB %10001101 ; B
DEFB %00100000 ; C
DEFB %10010011 ; D
DEFB %00010010 ; E
DEFB %11001101 ; F
DEFB %00101000 ; G
DEFB %11000011 ; H
DEFB %00001010 ; I
DEFB %10111001 ; J
DEFB %01000011 ; K
Map0015
DEFB %01101111 ; A
DEFB %10110001 ; B
DEFB %00000010 ; C
DEFB %11001011 ; D
DEFB %00010100 ; E
DEFB %11100111 ; F
DEFB %00001000 ; G
DEFB %10000001 ; H
DEFB %00001010 ; I
DEFB %11111001 ; J
DEFB %00000011 ; K
Map0016
DEFB %01111111 ; A
DEFB %10001001 ; B
DEFB %00100000 ; C
DEFB %10110111 ; D
DEFB %00000000 ; E
DEFB %11011001 ; F
DEFB %00100000 ; G
DEFB %10000111 ; H
DEFB %00001000 ; I
DEFB %11111001 ; J
DEFB %00000011 ; K
Map0017
DEFB %01111111 ; A
DEFB %10010001 ; B
DEFB %00000010 ; C
DEFB %11101011 ; D
DEFB %00010100 ; E
DEFB %10000111 ; F
DEFB %00101000 ; G
DEFB %11000001 ; H
DEFB %00001010 ; I
DEFB %10111001 ; J
DEFB %00100011 ; K
Map0018
DEFB %01111111 ; A
DEFB %10100101 ; B
DEFB %00001000 ; C
DEFB %11001011 ; D
DEFB %00000010 ; E
DEFB %10110011 ; F
DEFB %01001000 ; G
DEFB %10000101 ; H
DEFB %00001000 ; I
DEFB %11111011 ; J
DEFB %00000010 ; K
Map0019
DEFB %01111011 ; A
DEFB %10101101 ; B
DEFB %00000000 ; C
DEFB %11010011 ; D
DEFB %00100010 ; E
DEFB %10101101 ; F
DEFB %01001000 ; G
DEFB %10000011 ; H
DEFB %00001010 ; I
DEFB %11111001 ; J
DEFB %00000011 ; K
Map0020
DEFB %01101111 ; A
DEFB %10110001 ; B
DEFB %00000100 ; C
DEFB %11001011 ; D
DEFB %00000010 ; E
DEFB %10110011 ; F
DEFB %00101000 ; G
DEFB %10000101 ; H
DEFB %01001010 ; I
DEFB %10111001 ; J
DEFB %00100011 ; K
Map0021
DEFB %01110111 ; A
DEFB %10011001 ; B
DEFB %00100010 ; C
DEFB %10100011 ; D
DEFB %00000100 ; E
DEFB %11110101 ; F
DEFB %00001000 ; G
DEFB %11000011 ; H
DEFB %00001010 ; I
DEFB %10111001 ; J
DEFB %00100011 ; K
Map0022
DEFB %01110111 ; A
DEFB %10011001 ; B
DEFB %00100010 ; C
DEFB %10100011 ; D
DEFB %00000100 ; E
DEFB %11110001 ; F
DEFB %00000101 ; G
DEFB %11000101 ; H
DEFB %00001000 ; I
DEFB %10111011 ; J
DEFB %01000010 ; K
Map0023
DEFB %01111111 ; A
DEFB %10100101 ; B
DEFB %00000000 ; C
DEFB %11011011 ; D
DEFB %00000000 ; E
DEFB %10111111 ; F
DEFB %01000000 ; G
DEFB %10000101 ; H
DEFB %00001000 ; I
DEFB %11111011 ; J
DEFB %00000010 ; K
Map0024
DEFB %00111111 ; A
DEFB %11010001 ; B
DEFB %00000100 ; C
DEFB %10101011 ; D
DEFB %00110010 ; E
DEFB %10001001 ; F
DEFB %00110000 ; G
DEFB %10000111 ; H
DEFB %00101000 ; I
DEFB %10111001 ; J
DEFB %01000011 ; K
Map0025 ; at 11 bytes
DEFB %01111011 ; A ; left wall, bit 0 right is the top left corner of the map data
DEFB %10001101 ; B ; next column in, bit 0 and bit 7 are the outer walls
DEFB %00010000 ; C
DEFB %11100011 ; D
DEFB %00001010 ; E
DEFB %10001101 ; F
DEFB %00110000 ; G
DEFB %10000011 ; H
DEFB %01001010 ; I
DEFB %10111001 ; J
DEFB %00100011 ; K ; middle column
DEFW 255
UDGs
DEFB 000,000,000,000,000,000,000,000
DEFB 195,195,195,195,195,231,126,060
DEFB 063,127,224,192,192,224,127,063
DEFB 195,195,192,192,192,224,127,063
DEFB 060,126,231,195,195,195,195,195
DEFB 195,195,195,195,195,195,195,195
DEFB 063,127,224,192,192,192,195,195
DEFB 195,195,192,192,192,192,195,195
DEFB 252,254,007,003,003,007,254,252
DEFB 195,195,003,003,003,007,254,252
DEFB 255,255,000,000,000,000,255,255
DEFB 195,195,000,000,000,000,255,255
DEFB 252,254,007,003,003,003,195,195
DEFB 195,195,003,003,003,003,195,195
DEFB 255,255,000,000,000,000,195,195
DEFB 195,195,000,000,000,000,195,195
DEFB 060,126,231,195,195,231,126,060
DEFB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DEFB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Map
DEFB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0