diff --git a/Makefile b/Makefile index 6b53142..23b4fbd 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ APPLE2_CL := $(CC65_HOME)/bin/cl65 APPLE2_SRC := src/main.asm src/math.asm src/memory.asm src/random.asm \ src/game_loop.asm src/display.asm src/tiles.asm src/world.asm src/player.asm \ - src/debug.asm src/builder/builder.asm src/builder/rooms.asm src/builder/maze.asm src/display_map.asm \ + src/builder/builder.asm src/builder/rooms.asm src/builder/maze.asm src/builder/unite.asm \ + src/debug.asm src/display_map.asm \ src/io/title.asm src/io/textio.asm src/io/gr.asm APPLE2_MAP := escape.map APPLE2_CFLAGS := -Oirs -v -t apple2 -vm --cpu 6502 diff --git a/README.md b/README.md index 769f752..6a670fa 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ It is written in assembly and serves two purposes: 2. Document the proccess of coding for the Apple II on [my blog](https://www.xtof.info): - [A tile engine for the Apple II](https://www.xtof.info/blog/?p=1044) - [Raycasting a Line of Sight](https://www.xtof.info/blog/?p=1071) - - [Random level generation on Apple II](https://www.xtof.info/blog/?p=1186) # How to build @@ -19,10 +18,12 @@ Just type This will produce *bin/escape.a2* which is a binary executable for Apple's II PRODOS. -## Prerequisite in order to build: +##Prerequisite in order to build: The [cc65 compiler suite](https://github.com/cc65/cc65), with the environment variable *CC65_HOME* set to its folder +Tested OK with version V2.16 - Git be772c01 + ## Prerequisite in order to produce the disk image - Java Runtime @@ -33,9 +34,3 @@ The [cc65 compiler suite](https://github.com/cc65/cc65), with the environment va Run scripts/add-to-disk.sh - -# How to run - -In PRODOS type - - BRUN ESCAPE diff --git a/escape.dsk b/escape.dsk index aba82f2..e74d4ed 100644 Binary files a/escape.dsk and b/escape.dsk differ diff --git a/src/builder/builder.asm b/src/builder/builder.asm index 3cacc1a..fb13f9e 100644 --- a/src/builder/builder.asm +++ b/src/builder/builder.asm @@ -19,6 +19,7 @@ .include "rooms.inc" .include "maze.inc" +.include "unite.inc" .include "../io/textio.inc" .include "../monitor.inc" .include "../world.inc" @@ -63,6 +64,7 @@ STR_ROOMS: ASCIIZ "CARVING ROOMS..." STR_MAZE: ASCIIZ "GROWING THE MAZE..." STR_DOORS: ASCIIZ "OPENING DOORS..." STR_DEADENDS: ASCIIZ "FILLING DEAD ENDS..." +STR_UNITE: ASCIIZ "UNITING THE ROOMS..." .CODE @@ -243,5 +245,8 @@ Build_Level: PRINT STR_DEADENDS jsr Remove_Dead_Ends + PRINT STR_UNITE + jsr Unite_Rooms + rts diff --git a/src/builder/unite.asm b/src/builder/unite.asm new file mode 100644 index 0000000..5c85be7 --- /dev/null +++ b/src/builder/unite.asm @@ -0,0 +1,537 @@ + +; Copyright (C) 2020 Christophe Meneboeuf +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . + + + +.include "rooms.inc" +.include "maze.inc" +.include "../io/textio.inc" +.include "../world.inc" +.include "../memory.inc" +.include "../math.inc" + +.import World +.import Rooms +.import WIDTH_MAZE +.import HEIGHT_MAZE + +.import Compute_Maze_Addr + +.export Unite_Rooms + +.BSS + +.DATA + +.CODE + + +.define PTR_TILE ZERO_2_1 ; 2 bytes +.define ZONE_NR ZERO_2_4 +.define CPT_X ZERO_2_5 +.define CPT_Y ZERO_2_6 + + +.define FALSE #0 +.define TRUE #1 + +.define QUEUE_ADDR $4000 + + +.define REPLACED_NR ZERO_3 +.define PTR_QUEUE ZERO_4_1 ; 2 bytes +.define PTR_TILE_LOCAL ZERO_4_3 ; 2 bytes +.define FILL_NR ZERO_4_5 +; @param X fill color +; @param A replaced +; @return TRUE in A some tiles were filled, FALSE otherwise +_Flood_Fill : + + stx FILL_NR + ldy #0 + cmp (PTR_TILE), Y ; if (*ptr_tile != replaced) return; + beq fill_1 + lda FALSE + rts + +fill_1: + sta REPLACED_NR + txa + sta (PTR_TILE), Y + lda #QUEUE_ADDR + sta PTR_QUEUE+1 + ; offset ptr_tile by -width_world to be quickly accessed with an Y offset + lda PTR_TILE + sec + sbc #WIDTH_WORLD + sta QUEUE_ADDR + lda PTR_TILE+1 + sbc #0 + sta QUEUE_ADDR+1 + + ldx #0 + loop_fill: + + ; while ptr_queue >= QUEUE_ADDR + lda PTR_QUEUE + cmp #<(QUEUE_ADDR-2) + bne continue_fill + lda PTR_QUEUE+1 + cmp #>(QUEUE_ADDR-2) + bne continue_fill + jmp end_fill + + continue_fill: + ; ptr_tile = *(ptr_queue--); + ldy #0 + lda (PTR_QUEUE), Y + sta PTR_TILE_LOCAL + iny + lda (PTR_QUEUE), Y + sta PTR_TILE_LOCAL+1 + DEC16 PTR_QUEUE, #2 + + tile_west: + ; if (*tile_west == replaced) + ldy #(WIDTH_WORLD+1) + lda REPLACED_NR + cmp (PTR_TILE_LOCAL),Y + bne tile_east + ; *tile_west = fill; + lda FILL_NR + sta (PTR_TILE_LOCAL),Y + ; *(++ptr_queue) = tile_w + ADD16 PTR_QUEUE, #2 + clc + lda #1 + adc PTR_TILE_LOCAL + ldy #0 + sta (PTR_QUEUE),Y + lda #0 + adc PTR_TILE_LOCAL+1 + iny + sta (PTR_QUEUE),Y + + + tile_east: + ; if (*tile_east == replaced) + ldy #(WIDTH_WORLD-1) + lda REPLACED_NR + cmp (PTR_TILE_LOCAL),Y + bne tile_north + ; *tile_east = fill; + lda FILL_NR + sta (PTR_TILE_LOCAL),Y + ; *(++ptr_queue) = tile_tile_east + ADD16 PTR_QUEUE, #2 + sec + lda PTR_TILE_LOCAL + sbc #1 + ldy #0 + sta (PTR_QUEUE),Y + lda PTR_TILE_LOCAL+1 + sbc #0 + iny + sta (PTR_QUEUE),Y + + tile_north: + ; if (*tile_north == replaced) + ldy #0 + lda REPLACED_NR + cmp (PTR_TILE_LOCAL),Y + bne tile_south + ; *tile_north = fill; + lda FILL_NR + sta (PTR_TILE_LOCAL),Y + ; *(++ptr_queue) = tile_tile_north + ADD16 PTR_QUEUE, #2 + sec + lda PTR_TILE_LOCAL + sbc #WIDTH_WORLD + ldy #0 + sta (PTR_QUEUE),Y + lda PTR_TILE_LOCAL+1 + sbc #0 + iny + sta (PTR_QUEUE),Y + + tile_south: + ; if (*tile_south == replaced) + ldy #(2*WIDTH_WORLD) + lda REPLACED_NR + cmp (PTR_TILE_LOCAL),Y + bne end_tiles + ; *tile_south = fill; + lda FILL_NR + sta (PTR_TILE_LOCAL),Y + ; *(++ptr_queue) = tile_tile_south + ADD16 PTR_QUEUE, #2 + clc + lda #WIDTH_WORLD + adc PTR_TILE_LOCAL + ldy #0 + sta (PTR_QUEUE),Y + lda #0 + adc PTR_TILE_LOCAL+1 + iny + sta (PTR_QUEUE),Y + + end_tiles: + jmp loop_fill + + +end_fill: + lda TRUE + rts + + + +.define ROOM_NR ZERO_3 +.define SAVE_X ZERO_4_1 +.define PTR_ROOM ZERO_4_2 ; 2 bytes +.define ZONE_0 ACTORS::FLOOR_1 ; 1st useful zone: ZONE_1 +Unite_Rooms: + + ; *** flood fill room to identify separated zones *** + ; &Wordl[1][1] -> ptr_tile + clc + lda #World + adc #0 + sta PTR_TILE+1 + lda #1 + sta CPT_X + sta CPT_Y + + lda #ZONE_0 + sta ZONE_NR + inc ZONE_NR + + loop_flood: + ldx ZONE_NR + lda #ZONE_0 + jsr _Flood_Fill + cmp TRUE + bne loop_flood_next + inc ZONE_NR + + loop_flood_next: + ;next tile + ADD16 PTR_TILE, #1 + ; end line? + inc CPT_X + ldx CPT_X + cpx #WIDTH_WORLD-1 + bne loop_flood + ldx #0 + stx CPT_X + ; next + ADD16 PTR_TILE, #1 + ; the end? + inc CPT_Y + ldy CPT_Y + cpy #HEIGHT_WORLD-1 + bne loop_flood + + ; *** + ; reunite rooms that are not in the first zone + ; find the location of a room in zone_1 + ; Its origin will be targeted by th other zones to join + ; *** + .define SIZEOF_ROOM_T 4 + .define ROOM_ZONE_1 ZERO_5_4 + lda #0 ; FIXEME : useless? + sta ROOM_NR ; FIXEME : useless? + ldx #3 + lda #WIDTH_WORLD + sta FAC2 + loop_find_room: + lda Rooms, X + tay + stx SAVE_X + dex + lda Rooms, X + tax + jsr Compute_Maze_Addr + sta PTR_TILE+1 + stx PTR_TILE + ldy #0 + lda (PTR_TILE), Y + cmp #(ZONE_0 + 1) + beq room_found + ; next room + lda SAVE_X + clc + adc #(SIZEOF_ROOM_T) + tax + jmp loop_find_room + + room_found: + ldx SAVE_X + stx ROOM_ZONE_1 + + ; *** + ; Connect one room of each zone to the location found + .define END_LOOP_ZONE ZERO_5_1 + lda ZONE_NR + sta END_LOOP_ZONE + lda #(ZONE_0 + 2) ; zone_2 + cmp END_LOOP_ZONE + beq end_loop_zone ; only one zone + sta ZONE_NR + + ; loop over the zones + loop_zones: + + ldx #3 + loop_rooms: ; find a room of the zone + lda Rooms, X + tay + stx SAVE_X + dex + lda Rooms, X + tax + jsr Compute_Maze_Addr + stx ZERO_5_2 + sta ZERO_5_3 + ldy #0 + lda (ZERO_5_2), Y + cmp ZONE_NR + beq zone_found + ; next room + lda SAVE_X + clc + adc #(SIZEOF_ROOM_T) + tax + jmp loop_rooms + + zone_found: + jsr _Connect_Room + ; next zone + inc ZONE_NR + ; end loop? + lda END_LOOP_ZONE + cmp ZONE_NR + beq end_loop_zone + ; loop + jmp loop_zones + + end_loop_zone: + + + + rts + +; to compute ptr_romm += ix / iy or ptr_romm += ix / iy, the code is patched. +.macro PATCH_POS address, address2 + lda #$18 ; clc + sta address + sta address2 + lda #$69 ; adc imm + sta address+3 ; adc #1 / #WIDTH_WORLD + sta address+9 ; adc #0 + sta address2+3 ; adc #1 / #WIDTH_WORLD + sta address2+9 ; adc #0 +.endmacro +.macro PATCH_NEG address, address2 + lda #$38 ; sec + sta address + sta address2 + lda #$E9 ; sbc imm + sta address+3 ; sbc #1 / #WIDTH_WORLD + sta address+9 ; sbc #0 + sta address2+3 ; sbc #1 / #WIDTH_WORLD + sta address2+9 ; sbc #0 +.endmacro + +.define DELTA_X ZERO_5_2 +.define DELTA_Y ZERO_5_3 +.define DELTA_X_2 ZERO_5_5 +.define DELTA_Y_2 ZERO_5_6 +.define ROOM_Y ZERO_7_1 +.define ROOM_X ZERO_7_2 +.define D ZERO_3 +.define ROOM_FOUND SAVE_X +_Connect_Room: + + ; d = 0 + lda #0 + sta D + + ; delta_y = zone1_y - room->y + ldx ROOM_FOUND + lda Rooms, X + sta ROOM_Y ; room->y + dex + lda Rooms, X + sta ROOM_X ; room->x + ldx ROOM_ZONE_1 + lda Rooms, X ; zone1_y + sec + sbc ROOM_Y + sta DELTA_Y + ; delta_x = zone1_x - room->x + dex + lda Rooms, X ; zone1_x + sec + sbc ROOM_X + sta DELTA_X + + ; delta_x = delta_x > 0 ? delta_x : -delta_x + lda #0 + cmp DELTA_X + bmi end_abs_x + sec + sbc DELTA_X + sta DELTA_X + end_abs_x: + ; int dx2 = 2 * dx + asl + sta DELTA_X_2 + + ; delta_y = delta_y > 0 ? delta_y : -delta_y + abs_delta_y: + lda #0 + cmp DELTA_Y + bmi end_abs_y + sec + sbc DELTA_Y + sta DELTA_Y + end_abs_y: + ; int dy2 = 2 * dy + asl + sta DELTA_Y_2 + + ; uint8_t* ptr_room = &World[room->y][room->x] + ldx ROOM_X + ldy ROOM_Y + jsr Compute_Maze_Addr + stx PTR_ROOM + stx PTR_TILE + sta PTR_ROOM+1 + sta PTR_TILE+1 + + ldx ROOM_ZONE_1 + dex + ; int ix = room->x < zone1_x ? 1 : -1 + ix: + lda ROOM_X + cmp Rooms, X + bcc ix_positive + PATCH_NEG patch_ix1, patch_ix2 + jmp iy + ix_positive: + PATCH_POS patch_ix1, patch_ix2 + ; int iy = room->y < zone1_y ? WIDTH_WORLD : -WIDTH_WORLD; + iy: + inx + lda ROOM_Y + cmp Rooms, X + bcc iy_positive + PATCH_NEG patch_iy1, patch_iy2 + jmp iterate + iy_positive: + PATCH_POS patch_iy1, patch_iy2 + + iterate: + ldy #0 + lda DELTA_X + cmp DELTA_Y + bcc dy_sup + ; if (dx >= dy) + dx_sup: + while_1: + ; ptr_room += ix + patch_ix1: + ADD16 PTR_ROOM, #1 + ; d += dy2 + clc + lda DELTA_Y_2 + adc D + sta D + cmp DELTA_X + bcc d_infequal_dx + beq d_infequal_dx + ; if (d > dx) + ; ptr_room += iy + patch_iy1: + ADD16 PTR_ROOM, #WIDTH_WORLD + ; d -= dx2 + sec + lda D + sbc DELTA_X_2 + sta D + d_infequal_dx: + ; if (*ptr_room != zone_nr && *ptr_room <= WALKABLE) break; + lda (PTR_ROOM), Y ; Y = 0 + cmp ZONE_NR + beq continue_1 + cmp #ACTORS::WALKABLE + beq end + bpl continue_1 + jmp end + continue_1: + lda ZONE_NR + sta (PTR_ROOM), Y ; Y = 0 + jmp while_1 + dy_sup: + while_2: + ; ptr_room += iy + patch_iy2: + ADD16 PTR_ROOM, #WIDTH_WORLD + ; d += dx2 + clc + lda DELTA_X_2 + adc D + sta D + cmp DELTA_Y + bcc d_infequal_dy + beq d_infequal_dy + ;if (d > dy) { + ;ptr_room += ix; + patch_ix2: + ADD16 PTR_ROOM, #1 + ; d -= dy2 + sec + lda D + sbc DELTA_Y_2 + sta D + d_infequal_dy: + ; (*ptr_room != zone_nr && *ptr_room <= WALKABLE) + lda (PTR_ROOM), Y ; Y = 0 + cmp ZONE_NR + beq continue_2 + cmp #ACTORS::WALKABLE + beq end + bpl continue_2 + jmp end + continue_2: + lda ZONE_NR + sta (PTR_ROOM), Y ; Y = 0 + jmp while_2 + end: + + ; flood fills works on ptr_tile + ldx #(ZONE_0 + 1) + lda ZONE_NR + jsr _Flood_Fill + + + rts \ No newline at end of file diff --git a/src/builder/unite.inc b/src/builder/unite.inc new file mode 100644 index 0000000..1ffdc85 --- /dev/null +++ b/src/builder/unite.inc @@ -0,0 +1,16 @@ +; Copyright (C) 2020 Christophe Meneboeuf +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . + +.import Unite_Rooms \ No newline at end of file diff --git a/src/main.asm b/src/main.asm index 10555ab..67abbc6 100644 --- a/src/main.asm +++ b/src/main.asm @@ -67,13 +67,13 @@ _main: jsr Title ; will init the seed ; overwrite the seed to debug - ; lda #$5A + ; lda #$E6 ; sta SEED0 - ; lda #$5D + ; lda #$CE ; sta SEED1 - ; lda #0 + ; lda #$AD ; sta SEED2 - ; lda #0 + ; lda #$03 ; sta SEED3 jsr Random8_Init diff --git a/src/math.asm b/src/math.asm index 6a77e44..2de6e7e 100644 --- a/src/math.asm +++ b/src/math.asm @@ -20,24 +20,85 @@ mul8: lda #$00 ldx #$08 - clc + clc m0: bcc m1 - clc + clc adc FAC2 -m1: ror +m1: ror ror FAC1 - dex + dex bpl m0 ldx FAC1 - rts + + rts +; 8 bit division +; Inputs: +; FAC1 = 8-bit numerator +; FAC2 = 8-bit denominator +; Outputs: +; FAC1 = 8-bit quotient of TQ / B +; A = remainder of TQ / B +; source: http://6502org.wikidot.com/software-math-intdiv +; div8: +; lda #0 +; ldx #8 +; asl FAC1 +; lbl_1: +; rol A +; cmp FAC2 +; bcc lbl_2 +; sbc FAC2 +; lbl_2: +; rol FAC1 +; dex +; bne lbl_1 +; rts + + +; source: https://www.codebase64.org/doku.php?id=base:8bit_divide_8bit_product +; 8bit/8bit division +; by White Flame +; +; Input: num, denom in zeropage +; Output: num = quotient, .A = remainder + +; div8: +; lda #$00 +; ldx #$07 +; clc +; : rol FAC1 +; rol +; cmp FAC2 +; bcc :+ +; sbc FAC2 +; : dex +; bpl :-- +; rol FAC1 + +; 19 bytes +; +; Best case = 154 cycles +; Worst case = 170 cycles +; +; With immediate denom: +; Best case = 146 cycles +; Worst case = 162 cycles +; +; Unrolled with variable denom: +; Best case = 106 cycles +; Worst case = 127 cycles +; +; Unrolled with immediate denom: +; Best case = 98 cycles +; Worst case = 111 cycles ; Returns A % X in A ; Source: http://forum.6502.org/viewtopic.php?t=130 Modulus: - sec + sec stx FAC2 lbl_modulus: sbc FAC2 @@ -45,4 +106,4 @@ lbl_modulus: adc FAC2 - rts + rts diff --git a/src/math.inc b/src/math.inc index 52d5226..9f2bd8b 100644 --- a/src/math.inc +++ b/src/math.inc @@ -19,6 +19,7 @@ .import mul8 .import Modulus +.import div8 ; Inverts a positive number to its 2's complement counterpart ; The bits are all reversed then one is added @@ -29,3 +30,26 @@ clc adc #$01 .endmacro + + +.macro ADD16 addr, cste + clc + lda addr + adc cste + sta addr + lda addr+1 + adc #0 + sta addr+1 +.endmacro + + +.macro DEC16 addr, cste + sec + lda addr + sbc cste + sta addr + lda addr+1 + sbc #0 + sta addr+1 +.endmacro + diff --git a/src/tiles.asm b/src/tiles.asm index 8fc9185..8d90b2c 100644 --- a/src/tiles.asm +++ b/src/tiles.asm @@ -37,39 +37,39 @@ PLAYER: .byte 16, 16, 66, 0 .byte 16, 20, 74, 0 FLOOR_1: -.byte 85, 42, 85, 42 -.byte 1, 32, 0, 0 -.byte 1, 32, 0, 0 -.byte 1, 32, 0, 0 -.byte 1, 32, 0, 0 -.byte 1, 32, 0, 0 -.byte 1, 32, 0, 0 -.byte 1, 32, 0, 0 -.byte 1, 32, 0, 0 -.byte 85, 42, 85, 42 -.byte 16, 0, 64, 0 -.byte 16, 0, 64, 0 -.byte 16, 0, 64, 0 -.byte 16, 0, 64, 0 -.byte 16, 0, 64, 0 -.byte 16, 0, 64, 0 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 +.byte $00, $00, $00, $00 FLOOR_2: -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 -.byte $00, $00, $00, $00 +.byte 85, 42, 85, 42 +.byte 1, 32, 0, 0 +.byte 1, 32, 0, 0 +.byte 1, 32, 0, 0 +.byte 1, 32, 0, 0 +.byte 1, 32, 0, 0 +.byte 1, 32, 0, 0 +.byte 1, 32, 0, 0 +.byte 1, 32, 0, 0 +.byte 85, 42, 85, 42 +.byte 16, 0, 64, 0 +.byte 16, 0, 64, 0 +.byte 16, 0, 64, 0 +.byte 16, 0, 64, 0 +.byte 16, 0, 64, 0 +.byte 16, 0, 64, 0 FLOOR_3: .byte $55, $2A, $55, $2A .byte $55, $2A, $55, $2A diff --git a/src/world.asm b/src/world.asm index f46325a..eb22164 100644 --- a/src/world.asm +++ b/src/world.asm @@ -152,44 +152,3 @@ Compute_Maze_Addr: .align 256 World: .res (WIDTH_WORLD) * (HEIGHT_WORLD) -; .byte 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06 -; .byte 06, 02, 02, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06 -; .byte 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06 -; .byte 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06 -; .byte 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06 -; .byte 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06 -; .byte 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 06, 06, 06 -; .byte 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06 -; .byte 06, 06, 06, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 06 -; .byte 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06 -; .byte 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06 -; .byte 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 02, 02, 02, 02, 06, 06, 06 -; .byte 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 02, 02, 02, 02, 06, 06, 06 -; .byte 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 02, 02, 02, 02, 06, 06, 06 -; .byte 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 02, 02, 02, 02, 06, 06, 06 -; .byte 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06 -; .byte 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06 -; .byte 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06 -; .byte 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06 -; .byte 06, 06, 06, 06, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06 -; .byte 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06 -; .byte 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06 -; .byte 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06 -; .byte 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06 -; .byte 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06 -; .byte 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06 -; .byte 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06 -; .byte 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06 -; .byte 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06 -; .byte 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06 -; .byte 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06 -; .byte 06, 06, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06 -; .byte 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 06 -; .byte 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06 -; .byte 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06 -; .byte 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 06 -; .byte 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06 -; .byte 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06 -; .byte 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 02, 02, 02, 02, 02, 02, 06, 06, 06, 02, 02, 02, 06, 06, 06 -; .byte 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06 - diff --git a/src/world.inc b/src/world.inc index bdc9533..289d15a 100644 --- a/src/world.inc +++ b/src/world.inc @@ -7,7 +7,9 @@ .define MAXIMUM_WIDTH_MAZE 64 ; must be a power of 2 .define MAXIMUM_HEIGHT_MAZE 64 ; must be a power of 2 .define WIDTH_WORLD 64 +.define NEG_WIDTH_WORLD $C0 .define HEIGHT_WORLD 64 +.define NEG_HEIGHT_WORLD 64 $C0 .enum ACTORS @@ -15,7 +17,7 @@ PLAYER = 0 FLOOR_1 = 1 - FLOOR_2 + FLOOR_2 ; FLOOR BY DEFAULT FLOOR_3 FLOOR_4 WALKABLE = FLOOR_4 ; Player won't be allowed to go on anything > WALKABLE