Raycasting a line of sight (post #2: https://www.xtof.info/blog/?p=1071)

This commit is contained in:
Christophe Meneboeuf 2019-01-09 15:20:30 +01:00
parent 339a48deaf
commit d4c1056f33
23 changed files with 1975 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
.vscode/
*.out
*.a2
*.o
*.map
*.bak
*.s

18
Makefile Normal file
View File

@ -0,0 +1,18 @@
APPLE2_CL := $(CC65_HOME)/bin/cl65
APPLE2_SRC := src/main.asm src/math.asm src/random.asm \
src/game_loop.asm src/display.asm src/tiles.asm src/world.asm src/player.asm \
src/debug.asm
APPLE2_MAP := escape.map
APPLE2_CFLAGS := -Oirs -v -t apple2 -vm --cpu 6502
APPLE2_OUT := bin/escape.a2
all: directories apple2
directories:
mkdir -p bin
apple2: $(APPLE2_SRC)
$(APPLE2_CL) -m $(APPLE2_MAP) -o $(APPLE2_OUT) $? $(APPLE2_CFLAGS) -C src/escape.cfg
clean: $(SRC)
rm -f $(APPLE2_MAP) src/*.o src/*.s gmon.out & rm -r bin/

34
README.md Normal file
View File

@ -0,0 +1,34 @@
# What is it?
**Escape** (working title) is a homebrew *Rogue-Like** game developped for the Apple II computers.
It is written in assembly and serves two purposes:
1. Be fun
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)
# How to build
## Building
Just type
make
This will produce *bin/escape.a2* which is a binary executable for Apple's II PRODOS.
##Prerequisite in order to build:
The [cc65 compiler suite](https://github.com/cc65/cc65), with the environment variable *CC65_HOME* set to its folder
## Prerequisite in order to produce the disk image
- Java Runtime
- [AppleCommander](http://applecommander.sourceforge.net/)
## Embedding the Apple II' executable into the disk image
Run
scripts/add-to-disk.sh

BIN
escape.dsk Normal file

Binary file not shown.

19
scripts/add-to-disk.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Adds the required files to the provided disk.dsk
# usage: add_to_disk PATH_TO_APPLECOMMANDER.jar PATH_TO_BINARY.a2 PATH_TO_DISK
set -e
if (( $# != 3 )); then
echo "Bad number of arguments"
echo "usage: add_to_disk.sh PATH_TO_APPLECOMMANDER.jar PATH_TO_BINARY.a2 PATH_TO_DISK"
exit
fi
echo " . revoving previous instance of ESCAPE form the disk"
java -jar ${1} -d ${3} ESCAPE
echo " .. adding ESCAPE to the disk"
java -jar ${1} -cc65 ${3} ESCAPE BIN < ${2}
echo "DONE."

93
scripts/los.py Normal file
View File

@ -0,0 +1,93 @@
# Copyright (C) 2019 Christophe Meneboeuf <christophe@xtof.info>
#
# 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 <http://www.gnu.org/licenses/>.
#
from bresenham import bresenham
from PIL import Image, ImageDraw
import os
SIZE_GRID = 10
SIZE_TILE = 64
WIDTH_WORLD = 64
x_player = int(SIZE_GRID/2)
y_player = int(SIZE_GRID/2)
Im = Image.new('RGB',(SIZE_GRID*SIZE_TILE,SIZE_GRID*SIZE_TILE),(255,255,255))
Draw = ImageDraw.Draw(Im)
# fills a rectangle with the given color
def fill_rect(x,y,color):
Draw.rectangle([SIZE_TILE*x,SIZE_TILE*y,
SIZE_TILE*x+SIZE_TILE-1,SIZE_TILE*y+SIZE_TILE-1],
outline = (0,0,128),
fill = color)
if __name__=="__main__":
rays = []
y = 0
for x in range(0,SIZE_GRID-1):
rays.append(list(bresenham(x_player,y_player,x,y)))
x = SIZE_GRID-1
for y in range(0,SIZE_GRID-1):
rays.append(list(bresenham(x_player,y_player,x,y)))
y = SIZE_GRID-1
for x in range(SIZE_GRID-1,0,-1):
rays.append(list(bresenham(x_player,y_player,x,y)))
x = 0
for y in range(SIZE_GRID-1,0,-1):
rays.append(list(bresenham(x_player,y_player,x,y)))
# create the grid
for x in range(0,SIZE_GRID):
for y in range(0,SIZE_GRID):
fill_rect(x,y,(255,255,255))
# fill the player
fill_rect(x_player,y_player,(0,255,0))
# fill the rays
nb_cells = 0
rgb = 0
for ray in rays:
for tile in ray[1:]:
fill_rect(tile[0], tile[1], (rgb,rgb,rgb))
nb_cells += 1
rgb += int(200 / len(rays))
# print rays
# [[len(ray), offset_view, offset_world]]
# offset_world: offset in the world from the 1st tile viewed
str_ray = "; Nb rays: {}\n".format(len(rays))
str_ray += "; A ray: length (nb_tiles), offset_from_view_in_world_low, offset_from_view_in_world_high, offset_view\nRays:\n"
for ray in rays:
str_ray += ".byte " + str(len(ray)-1)
for tile in ray[1:]:
offset_view = tile[0] + SIZE_GRID*tile[1]
offset_world = (tile[0] + WIDTH_WORLD*tile[1])
offset_world_low = offset_world & 0xFF
offset_world_high = (offset_world >> 8) & 0xFF
str_ray += ", " + str(offset_world_low) + ", " + str(offset_world_high) + ", " + str(offset_view)
str_ray += "\n"
print(str_ray)
Im.show()

41
src/debug.asm Normal file
View File

@ -0,0 +1,41 @@
; nb of bytes to be displayed in DBG_TRACES[0]
.export DBG_TRACE
; bytes to be displayed
.export DBG_TRACES
.CODE
.define STROUT $DB3A ; Applesoft: OUTPUTS AY-POINTED NULL TERMINATED STRING
.define LINPTR $ED24 ; Applesoft: Displays the number A(high)X(low) in decimal
; Traces the number of TRACES requested
DBG_TRACE:
ldy #>str_trace
lda #<str_trace
jsr STROUT
lda #0
loop:
tax
inx
txa
pha
lda DBG_TRACES, X
tax
lda #0
jsr LINPTR
ldy #>str_space
lda #<str_space
jsr STROUT
pla
cmp DBG_TRACES
bne loop
rts
.DATA
str_trace: .byte 13, "TRACE: ", 0
str_space: .byte " ", 0
.BSS
DBG_TRACES: .res 7 ; bytes to be displayed by TRACE

512
src/display.asm Normal file
View File

@ -0,0 +1,512 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
.include "display.inc"
.include "world.inc"
.include "tiles.inc"
.include "math.inc"
.include "memory.inc"
.include "monitor.inc"
; Init the view. To be called before anything else!
.export view_init
; Refreshes the view to reflect the world
; destroyed: ZERO_2_1 & ZERO_2_2
.export view_refresh
; Places the upper left corner of the *view* on the given coordinates
; X: in x (values [0:255])
; Y: in y (values [0:255])
; destroyed: ZERO_2_1
.export set_view_coords ; routine to place the view over the world
; Shows a tile at the provided coordinates
; Tile number to be displayed : TILE_NR
; X: TILE_COORD_X
; Y: TILE_COORD_Y
.import compute_maze_addr
.import World
.import Player_XY
.import DBG_TRACE
.import DBG_TRACES
.CODE
; ********* PRIVATE CONSTANTS ********
; shall be even
.define GRID_WIDTH $A
; shall be even
.define GRID_HEIGHT $A
; location of th eplayer in the view
.define PLAYER_X GRID_WIDTH/2
.define PLAYER_Y GRID_HEIGHT/2
; sizeof the structure describing a "free tile":
; struct { int8_t* p_in_world; int8_t offset_from_player }
.define SIZEOF_TILETRANSP_T 3
; ********* USEFUL VARIABLES & LOCATIONS *******
; x location
.define TILE_COORD_X ZERO_5_3
; y location
.define TILE_COORD_Y ZERO_5_4
; Address of the first tile in the world to be viewed
.define VIEW_WORLD ZERO_4_1
view_init:
; inits the current view to an impossible value
; for the first screen refresh
ldx #(GRID_HEIGHT*GRID_WIDTH - 1)
lda #$FF
sta View_Current
loop_view_init:
sta View_Current, x
dex
bne loop_view_init
; sets the text portion of the mixed mode
lda #$14
sta WNDTOP ; sets the beginning of the text
jsr HOME ; clear the text screen and positions the "cursor"
jsr HGR ; HIRES mixed mode, page 1
rts
; this routine will create the view and populate View_Future
; destroys ZERO_4_3, ZERO_4_4, ZERO_5_1, ZERO_5_2, ZERO_5_3
; ZERO_5_4, ZERO_5_5, ZERO_5_6, ZERO_7_1, ZERO_7_2
_build_view:
; 1 - Init the view
lda #0
ldx #(GRID_WIDTH * GRID_HEIGHT - 1)
loop_init_view:
lda #ACTORS::UNKNOWN
sta View_Future,X
dex
bne loop_init_view
sta View_Future,X
; 2 - Player
.define OFFSET_PLAYER_IN_VIEW PLAYER_X+PLAYER_Y*GRID_WIDTH
ldx #(OFFSET_PLAYER_IN_VIEW)
lda #ACTORS::PLAYER
sta View_Future,X
; 3 - Casting rays
.define NB_RAYS 36
.define NB_ITER ZERO_4_3
.define NB_TILES_IN_RAY ZERO_4_4
.define NB_TILES_IN_RAY_LEFT ZERO_5_1
.define SRC_TILE_IN_WORLD ZERO_5_2 ; 2 bytes
.define PTR_RAY ZERO_5_4 ; 2 bytes
.define TMP ZERO_5_6
; loading ptr_rays - 1 as it will be incremented
; at the 1st iteration of the loop
lda #<Rays
sec
sbc #1
sta PTR_RAY
lda #>Rays
sbc #0
sta PTR_RAY+1
ldx #0
stx NB_TILES_IN_RAY
loop_rays:
stx NB_ITER
; computing the pointer to the ray to be casted
; ptr_ray += sizeof(ray_elem)*nb elem
lda NB_TILES_IN_RAY
sta FAC1
lda #3 ; sizeof(ray_elem) = 1 byte (offset_view) + 2 bytes (offset_world)
sta FAC2
jsr mul8 ; result is alway 8 bit
inx ; result += 1
txa
clc
adc PTR_RAY ; incrementing the ptr to the current ray
sta PTR_RAY
lda #0
adc PTR_RAY+1
sta PTR_RAY+1
; loading nb tiles in ray
ldy #0
lda (PTR_RAY),Y
tax
stx NB_TILES_IN_RAY
iny
loop_ray:
stx NB_TILES_IN_RAY_LEFT
lda VIEW_WORLD
clc
adc (PTR_RAY),Y ; offset_tile_world_low
sta SRC_TILE_IN_WORLD
lda VIEW_WORLD+1
iny
adc (PTR_RAY),Y ; offset_tile_world_high
sta SRC_TILE_IN_WORLD+1
iny
sty TMP
lda (PTR_RAY),Y ; offset_view
tax
ldy #0
lda (SRC_TILE_IN_WORLD),Y
sta View_Future,X
ldy TMP
iny
; break if non-transparent
cmp #ACTORS::NOT_TRANSPARENT
bcs end_loop_ray
; loop if tiles are left in the ray
ldx NB_TILES_IN_RAY_LEFT
dex
bne loop_ray
end_loop_ray:
ldx NB_ITER
inx
cpx #NB_RAYS
bne loop_rays
end_loop_rays:
rts
.undef OFFSET_PLAYER_IN_VIEW
.undef NB_RAYS
.undef NB_ITER
.undef NB_TILES_IN_RAY
.undef NB_TILES_IN_RAY_LEFT
.undef SRC_TILE_IN_WORLD
.undef PTR_RAY
.undef TMP
;.align 256
; This routine refreshes (updates) the screen.
; It won't update tiles that are not modified
; destroys ZERO_2_1, ZERO_2_2,
; ZERO_4_3, ZERO_4_4, ZERO_5_1, ZERO_5_2, ZERO_5_3,
; ZERO_5_4, ZERO_5_5, ZERO_5_6, ZERO_7_1, ZERO_7_2
view_refresh:
; 1 - computing the start address of the view
; to VIEW_WORLD. It places the top-left corner at the given offset
lda #<World
clc
adc View_Offset
sta VIEW_WORLD
lda #>World
adc View_Offset+1
sta VIEW_WORLD+1
; 2 - shifting the view to place the center at the given offset
sec
lda VIEW_WORLD
sbc SHIFT_VIEW
sta VIEW_WORLD
lda VIEW_WORLD+1
sbc SHIFT_VIEW+1
sta VIEW_WORLD+1
; 3 - build the view to be displayed
jsr _build_view
; 4 - display the tiles viewed
.define SAVE_X ZERO_3
lda #0
tax
sta TILE_COORD_Y
loop_display_tiles_y:
ldy #0
sty TILE_COORD_X
loop_display_tiles_x:
lda View_Future, X
cmp View_Current, X
beq no_display ; do not display an unchanged tile
sta View_Current, X ; update the list of diplayed tiles
sta TILE_NR
stx SAVE_X
jsr _set_tile ; this routines does not alter its parameters
ldx SAVE_X
no_display:
inx
inc TILE_COORD_X
ldy TILE_COORD_X
tya
cmp #GRID_WIDTH
bne loop_display_tiles_x
; next line
inc TILE_COORD_Y
lda TILE_COORD_Y
cmp #GRID_HEIGHT
bne loop_display_tiles_y
rts
.undef VIEW_WORLD
SHIFT_VIEW: .word WIDTH_MAZE*PLAYER_Y + PLAYER_X ; shift to center the view on the player
.CODE
set_view_coords:
; 1. Compute offset from the starting address of the maze
stx ZERO_2_1
sty FAC1
lda #WIDTH_MAZE
sta FAC2
jsr mul8
tay ; high part
txa ; low part
clc
adc ZERO_2_1
sta View_Offset ; little endian
tya
adc #0
sta View_Offset+1 ; little endian
rts
;.align 256
; displays tile #TILE_NR at [TILE_COORD_X, TILE_COORD_Y]
; destroys ZERO_2_1, ZERO_2_2
_set_tile:
.define ADDR_TO_PATCH $666 ; 2 byte address to be patched by tile's address
; A tile being 16 line tall, it will vertically spawn on two 8 line "blocks"
.define ADDR_DST_BLOCK_1 ZERO_2_1 ; first block
.define ADDR_DST_BLOCK_2 ZERO_2_3 ; second bloc
; 1 - patching the code with the adress
; of the tile to be displayed
lda TILE_NR
asl
tax
lda TILES, X
sta PATCH_1+1
sta PATCH_2+1
sta PATCH_3+1
sta PATCH_4+1
sta PATCH_5+1
sta PATCH_6+1
sta PATCH_7+1
sta PATCH_8+1
lda TILES+1, X
sta PATCH_1+2
sta PATCH_2+2
sta PATCH_3+2
sta PATCH_4+2
sta PATCH_5+2
sta PATCH_6+2
sta PATCH_7+2
sta PATCH_8+2
; destination address (HGR)
; 2 - get the offset from HGR_GRID (view)
lda #GRID_WIDTH
sta FAC1
lda TILE_COORD_Y
sta FAC2
jsr mul8 ; X = GRID_WITH * Y (always < 0xFF)
txa
clc
adc TILE_COORD_X ; Won't set the carry
asl ; 16 bit elements: doubling the offset. Won't work if grid > 127 tiles (ie 20x10)
tay ; Y: offset to get the address
; 3 - retrieve the destination address
lda HGR_GRID, Y
sta ADDR_DST_BLOCK_1
adc #$80
sta ADDR_DST_BLOCK_2
lda HGR_GRID+1, Y
sta ADDR_DST_BLOCK_1+1
sta ADDR_DST_BLOCK_2+1
; 4 - Draw
ldx #0 ; loop counter & index source
.define NB_ITER_1 #$20
; First loop: draw lines 1 to 8
loop_lines_1to8:
ldy #0 ; index destination
; copy lines (4 blocks)
PATCH_1:
lda ADDR_TO_PATCH, X
sta (ADDR_DST_BLOCK_1), Y
iny
inx
PATCH_2:
lda ADDR_TO_PATCH, X
sta (ADDR_DST_BLOCK_1), Y
iny
inx
PATCH_3:
lda ADDR_TO_PATCH, X
sta (ADDR_DST_BLOCK_1), Y
iny
inx
PATCH_4:
lda ADDR_TO_PATCH, X
sta (ADDR_DST_BLOCK_1), Y
iny
inx
; next line
lda ADDR_DST_BLOCK_1+1
ADC #$4 ; addr += 0x400
sta ADDR_DST_BLOCK_1+1
cpx NB_ITER_1
bne loop_lines_1to8
clc ; cpx affects carry
.define NB_ITER_2 #$40
; Second loop: draw lines 9 to 16
loop_lines_9to16:
ldy #0 ; index destination
; copy lines (4 blocks)
_DISP_TILE_2:
PATCH_5:
lda ADDR_TO_PATCH, X
sta (ADDR_DST_BLOCK_2), Y
iny
inx
PATCH_6:
lda ADDR_TO_PATCH, X
sta (ADDR_DST_BLOCK_2), Y
iny
inx
PATCH_7:
lda ADDR_TO_PATCH, X
sta (ADDR_DST_BLOCK_2), Y
iny
inx
PATCH_8:
lda ADDR_TO_PATCH, X
sta (ADDR_DST_BLOCK_2), Y
iny
inx
; next line
lda ADDR_DST_BLOCK_2+1
ADC #$4 ; addr += 0x400
sta ADDR_DST_BLOCK_2+1
cpx NB_ITER_2
bne loop_lines_9to16
rts
.DATA
; Adress of the tiles in the HIRES screen
; T0 T1 T2
; T3 T4 T5
HGR_GRID:
.word $2000, $2004, $2008, $200C, $2010, $2014, $2018, $201C, $2020, $2024
.word $2100, $2104, $2108, $210C, $2110, $2114, $2118, $211C, $2120, $2124
.word $2200, $2204, $2208, $220C, $2210, $2214, $2218, $221C, $2220, $2224
.word $2300, $2304, $2308, $230C, $2310, $2314, $2318, $231C, $2320, $2324
.word $2028, $202C, $2030, $2034, $2038, $203C, $2040, $2044, $2048, $204C
.word $2128, $212C, $2130, $2134, $2138, $213C, $2140, $2144, $2148, $214C
.word $2228, $222C, $2230, $2234, $2238, $223C, $2240, $2244, $2248, $224C
.word $2328, $232C, $2330, $2334, $2338, $233C, $2340, $2344, $2348, $234C
.word $2050, $2054, $2058, $205C, $2060, $2064, $2068, $206C, $2070, $2074
.word $2150, $2154, $2158, $215C, $2160, $2164, $2168, $216C, $2170, $2174
; Nb rays: 36
; A ray: length (nb_tiles), offset_from_view_in_world_low, offset_from_view_in_world_high, offset_view
Rays:
.byte 5, 4, 1, 44, 195, 0, 33, 130, 0, 22, 65, 0, 11, 0, 0, 0
.byte 5, 4, 1, 44, 195, 0, 33, 131, 0, 23, 66, 0, 12, 1, 0, 1
.byte 5, 4, 1, 44, 196, 0, 34, 131, 0, 23, 67, 0, 13, 2, 0, 2
.byte 5, 5, 1, 45, 196, 0, 34, 132, 0, 24, 67, 0, 13, 3, 0, 3
.byte 5, 5, 1, 45, 197, 0, 35, 132, 0, 24, 68, 0, 14, 4, 0, 4
.byte 5, 5, 1, 45, 197, 0, 35, 133, 0, 25, 69, 0, 15, 5, 0, 5
.byte 5, 5, 1, 45, 197, 0, 35, 134, 0, 26, 70, 0, 16, 6, 0, 6
.byte 5, 5, 1, 45, 198, 0, 36, 134, 0, 26, 71, 0, 17, 7, 0, 7
.byte 5, 6, 1, 46, 198, 0, 36, 135, 0, 27, 71, 0, 17, 8, 0, 8
.byte 5, 6, 1, 46, 199, 0, 37, 135, 0, 27, 72, 0, 18, 9, 0, 9
.byte 4, 6, 1, 46, 199, 0, 37, 136, 0, 28, 73, 0, 19
.byte 4, 6, 1, 46, 199, 0, 37, 200, 0, 38, 137, 0, 29
.byte 4, 6, 1, 46, 7, 1, 47, 200, 0, 38, 201, 0, 39
.byte 4, 70, 1, 56, 7, 1, 47, 8, 1, 48, 9, 1, 49
.byte 4, 70, 1, 56, 71, 1, 57, 72, 1, 58, 73, 1, 59
.byte 4, 70, 1, 56, 135, 1, 67, 136, 1, 68, 137, 1, 69
.byte 4, 134, 1, 66, 135, 1, 67, 200, 1, 78, 201, 1, 79
.byte 4, 134, 1, 66, 199, 1, 77, 200, 1, 78, 9, 2, 89
.byte 4, 134, 1, 66, 199, 1, 77, 8, 2, 88, 73, 2, 99
.byte 4, 134, 1, 66, 199, 1, 77, 7, 2, 87, 72, 2, 98
.byte 4, 134, 1, 66, 198, 1, 76, 7, 2, 87, 71, 2, 97
.byte 4, 133, 1, 65, 198, 1, 76, 6, 2, 86, 70, 2, 96
.byte 4, 133, 1, 65, 197, 1, 75, 5, 2, 85, 69, 2, 95
.byte 4, 133, 1, 65, 196, 1, 74, 4, 2, 84, 68, 2, 94
.byte 4, 132, 1, 64, 196, 1, 74, 3, 2, 83, 67, 2, 93
.byte 4, 132, 1, 64, 195, 1, 73, 3, 2, 83, 66, 2, 92
.byte 4, 132, 1, 64, 195, 1, 73, 2, 2, 82, 65, 2, 91
.byte 5, 132, 1, 64, 195, 1, 73, 194, 1, 72, 1, 2, 81, 64, 2, 90
.byte 5, 132, 1, 64, 131, 1, 63, 194, 1, 72, 193, 1, 71, 0, 2, 80
.byte 5, 68, 1, 54, 131, 1, 63, 130, 1, 62, 193, 1, 71, 192, 1, 70
.byte 5, 68, 1, 54, 67, 1, 53, 130, 1, 62, 129, 1, 61, 128, 1, 60
.byte 5, 68, 1, 54, 67, 1, 53, 66, 1, 52, 65, 1, 51, 64, 1, 50
.byte 5, 68, 1, 54, 67, 1, 53, 2, 1, 42, 1, 1, 41, 0, 1, 40
.byte 5, 68, 1, 54, 3, 1, 43, 2, 1, 42, 193, 0, 31, 192, 0, 30
.byte 5, 4, 1, 44, 3, 1, 43, 194, 0, 32, 193, 0, 31, 128, 0, 20
.byte 5, 4, 1, 44, 195, 0, 33, 194, 0, 32, 129, 0, 21, 64, 0, 10
.BSS
.align 256
View_Current: .res GRID_HEIGHT*GRID_WIDTH ; current displayed view
View_Offset: .res 2 ; offset of the corner from HGR_GRID (x,y)
Tiles_Transparent: .res GRID_WIDTH*SIZEOF_TILETRANSP_T ; Tiles on the same line as the player that don't block the view
; struct { int8_t* p_in_world; int8_t offset_from_player}
DBG_NB_REDRAW: .res 1
; This alignement is **MANDATORY** for the raycasting to work:
; only 8-bit additions are used to compute pointers in this view
.align 256
View_Future: .res GRID_HEIGHT*GRID_WIDTH ; next displayed view

19
src/display.inc Normal file
View File

@ -0,0 +1,19 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
.define TILE_NR ZERO_5_1 ; tile number to be displayed

24
src/escape.cfg Normal file
View File

@ -0,0 +1,24 @@
# Configuration for assembler programs which don't need a special setup
FEATURES {
STARTADDRESS: default = $0803;
}
SYMBOLS {
__EXEHDR__: type = import;
}
MEMORY {
ZP: file = "", start = $0000, size = $00FF;
HEADER: file = %O, start = %S - 4, size = $0004;
MAIN: file = %O, define = yes, start = %S, size = $C000 - %S;
BSS: file = "", start = __MAIN_LAST__, size = $C000 - __MAIN_LAST__;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
EXEHDR: load = HEADER, type = ro;
CODE: load = MAIN, type = rw;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes, align = $100;
BSS: load = BSS, type = bss, optional = yes, define = yes, align = $100;
# user defined segments
TILES: load = MAIN, type = ro, align = $100;
}

95
src/game_loop.asm Normal file
View File

@ -0,0 +1,95 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
.include "world.inc"
.include "display.inc"
.include "memory.inc"
.include "monitor.inc"
.export game_loop
; display / view
.import set_view_coords
.import view_refresh
; player
.import player_move_inx
.import player_move_iny
.import player_move_dex
.import player_move_dey
.import Player_XY
; world
.import world_set_player
.define KEY_UP $C9
.define KEY_LEFT $CA
.define KEY_DOWN $CB
.define KEY_RIGHT $CC
.CODE
game_loop:
ldx Player_XY
ldy Player_XY+1
jsr world_set_player
jsr set_view_coords
jsr view_refresh
; waiting for a key to be pressed
kbd_loop:
lda KEYBD
bpl kbd_loop ; bit #8 is set when a character is present (thus A < 0)
sta KEYBD_STROBE
jsr key_action
bvc kbd_loop
rts
; action on key pressed
key_action:
cmp #KEY_UP
beq move_up
cmp #KEY_RIGHT
beq move_right
cmp #KEY_DOWN
beq move_down
cmp #KEY_LEFT
beq move_left
rts
move_up:
jsr player_move_dey
bvc end_action_move
move_right:
jsr player_move_inx
bvc end_action_move
move_down:
jsr player_move_iny
bvc end_action_move
move_left:
jsr player_move_dex
bvc end_action_move
end_action_move: ; update player/view coordinates and refresh the display
jsr world_set_player
jsr set_view_coords ; coords of the player in XY after player_move_*
jsr view_refresh
rts

49
src/main.asm Normal file
View File

@ -0,0 +1,49 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
.include "random.inc"
.include "memory.inc"
.include "monitor.inc"
.export _main
.import world_init
.import player_init
.import view_init
.import game_loop
.CODE
_main:
; init the seed of rnd
lda #$DE
sta SEED0
lda #$AD
sta SEED1
lda #$BE
sta SEED2
lda #$EF
sta SEED3
jsr player_init
jsr world_init
jsr view_init
jsr game_loop
rts

31
src/math.asm Normal file
View File

@ -0,0 +1,31 @@
.include "memory.inc"
; Must be the same as in math.inc !!
.define FAC1 ZERO_7_1
.define FAC2 ZERO_7_2
.export mul8
.CODE
; Short 8bit * 8bit = 16bit multiply
; A small multiplication routine using the ancient egyptian multiplication algorithm.
; Factors should be stored in the FAC1 and FAC2 variables,
; the product can be found in A (high byte) and X (low byte).
; FAC1 will be destroyed. No tables required.
; Source: http://www.codebase64.org/doku.php?id=base:short_8bit_multiplication_16bit_product
mul8:
; A:X = FAC1 * FAC2
lda #$00
ldx #$08
clc
m0: bcc m1
clc
adc FAC2
m1: ror
ror FAC1
dex
bpl m0
ldx FAC1
rts

30
src/math.inc Normal file
View File

@ -0,0 +1,30 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
.define FAC1 ZERO_7_1
.define FAC2 ZERO_7_2
.import mul8
; Inverts a positive number to its 2's complement counterpart
; The bits are all reversed then one is added
; param : number to be inverted in in A
; result : in A
.macro NEG
eor #$FF ; %11111111 to reverse bits
clc
adc #$01
.endmacro

63
src/memory.inc Normal file
View File

@ -0,0 +1,63 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
; ********* ZERO PAGE *********
; Free locations in Zero Page: not used by either
; the Monitor, Applesoft, Integer Basic, DOS3.3 or PRODOS
; locations for the random generator
.define SEED0 $6
.define SEED1 $7
.define SEED2 $8
.define SEED3 $9
.define ZERO_2_1 $19
.define ZERO_2_2 $1A
.define ZERO_2_3 $1B
.define ZERO_2_4 $1C
.define ZERO_2_5 $1D
.define ZERO_2_6 $1E
.define ZERO_3 $E3
.define ZERO_4_1 $EB
.define ZERO_4_2 $EC
.define ZERO_4_3 $ED
.define ZERO_4_4 $EE
.define ZERO_4_5 $EF
.define ZERO_5_1 $FA
.define ZERO_5_2 $FB
.define ZERO_5_3 $FC
.define ZERO_5_4 $FD
.define ZERO_5_5 $FE
.define ZERO_5_6 $FF
; Used by Integer Basic
.define ZERO_7_1 $CE
.define ZERO_7_2 $CF
.define ZERO_8_1 $D6
.define ZERO_8_2 $D7
; ************ I/O ************
.define KEYBD $C000
.define KEYBD_STROBE $C010
; *********** HIRES ************
.define ADDR_HGR1 $2000

190
src/monitor.inc Normal file
View File

@ -0,0 +1,190 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
; ******************************************************
; This file contains aliases for Montitor's and Applesoft's routines
; ******************************************************
; ++++ ZERO PAGE ++++
.define WNDLFT $20 ; $20 Left edge of text window
.define WNDWDTH WNDLFT+1 ; $21 Width of text window
.define WNDTOP WNDWDTH+1 ; $22 Top of text window
.define WNDBTM WNDTOP+1 ; $23 Bottom+1 of text window
.define CH WNDBTM+1 ; $24 Cursor horizontal position
.define CV CH+1 ; $25 Cursor vertical position
.define BASL $28 ; $28 Text base address
.define BASH BASL+1 ; $29
.define INVFLG $32 ; $32 Normal/Inverse/Flash
.define PROMPT INVFLG+1 ; $33 Prompt character
.define CSWL $36 ; $36 Character output hook
.define CSWH CSWL+1 ; $37
.define KSWL CSWH+1 ; $38 Character input hook
.define KSWH KSWL+1 ; $39
; ++++ Monitor ++++
.define INIT $fb2f ; Initialize text screen
.define SETTXT $fb39 ; Set text mode
.define SETWND $fb4b ; Set text window size
.define SETWND2 $fb51 ; Set text window width and bottom size
.define TABV $fb5b ; Vertical tab
.define BASCALC $fbc1 ; Text base-address calculator
.define STORADV $fbf0 ; Place a printable character on the screen
.define ADVANCE $fbf4 ; Increment the cursor position
.define VIDOUT $fbfd ; Place a character on the screen
.define VTAB $fc22 ; Vertical tab
.define VTABZ $fc24 ; Vertical tab (alternate entry)
.define HOME $fc58 ; Home cursor and clear to end of page
.define RDKEY $fd0c ; Get an input character
.define CROUT $fd8e ; Issue a carriage return
.define PRBYTE $fdda ; Print a hexadecimal byte
.define COUT $fded ; Output a character
.define COUT1 $fdf0 ; Output a character to the screen
.define SETINV $fe80 ; Set inverse text mode
.define SETNORM $fe84 ; Set normal text mode
.define SETKBD $fe89 ; Reset input to keyboard
.define SETVID $fe93 ; Reset output to screen
; ++++ HIRES GFX ++++
; Colors
; SET #1
.define BLACK1 $0
.define GREEN $1
.define VIOLET $2
.define WHITE1 $3
; SET #2
.define BLACK2 $4
.define ORANGE $5
.define BLUE $6
.define WHITE2 $7
.define HGR $F3E2
; Initializes to hi-res page 1, clears screen.
.define HGR2 $F3D8
; Initializes to hi-res page 2, clears screen.
.define HCLR $F3F2
; Clears current screen to black1.
.define BKGND $F3F6
; Clears current screen to last plotted HCOLOR.
.define HCOLOR $F6F0
; Sets HCOLOR to contents of X-Register (07).
.define HPOSN $F411
; Positions hi-res “cursor” without plotting. Enter with
; X, Y (low, high) = horizontal position, Accumulator =
; vertical position.
.define HPLOT $F457
; Identical to HPOSN, but plots current HCOLOR at coordinates
; given.
.define HFIND $F5CB
; Returns current “cursor” position. Useful after aDRAW
; to find where youve been left. Coordinates returned in:
; $E0, $E1 = horizontal (low,high), $E2 = vertical.
.define HLIN $F53A
; Draws a line from last plot to point given. Accumulator,
; X (low, high) = horizontal, Y = vertical position.
.define SHNUM $F730
; Puts address of shape number indicated by X-Register
; into$1A,$1B; returns with X, Y (low, high) also set to
; address of that shape-table entry.
.define DRAW $F601
; Draw shape pointed to by X, Y (low, high) in current
; HCOLOR. Note: X, Y point to specific entry,not the
; beginning of the table. Call SHNUM first
.define XDRAW $F65D
; Erases shape just drawn (if there) by doing anexclusive
; OR with the screen data. Load X, Y (low, high) with
; address of shape toXDRAW or callSHNUM first with XRegister
; = shape numbe
; *********** STRINGS *************
.define GETSPACE $E452
; Reduces the start-of-strings
; pointer, FRETOP ($6F), by the
; number specified in the A-register
; (the string length) and sets up
; FRESPC ($71) so that it equals
; FRETOP. After this has been done,
; A remains unaffected and Y (high)
; and X (low) point to the beginning
; of the space. The string can
; then be moved into place in upper
; memory by using MOVESTR.
.define GARBAGE $E484
; Clears out old string definitions
; that are no longer being used and
; adjusts FRETOP {$6F) accordingly.
; (Each time that a string is
; redefined, its old definition is kept
; in memory but is not used.) This
; process is called "garbage collection"
; and is performed automatically
; whenever the start-ofstrings
; address, FRETOP, comes
; close to the end-of-variables address,
; STREND {$6D).
.define MOVESTR $E5E2
; Copies the string that is pointed
; to by Y (high) and X (low) and
; that has a length of A to the location
; pointed to by FRESPC
; ($71).
.define FOUT $ED34
; Converts the FAC into an ASCII
; character string that represents
; the number in decimal form (like
; Applesoft's STR$ function). The
; string is followed by a $00 byte
; and is pointed to by Y (high) and
; A (low) so that STROUT can be
; used to print the string.
.define STROUT $DB3A
; Prints the string pointed to by Y
; (high) and A (low). The string must
; be followed immediately by a $00
; or a $22 byte. All of these conditions
; are set up by FOUT.
.define STRPRT $DB3D
; Prints the string whose 3-byte descriptor
; is pointed to by $A0/$A1.
; FRMEVL sets up such a pointer
; when calculating string formulas.

169
src/player.asm Normal file
View File

@ -0,0 +1,169 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
.include "world.inc"
.include "memory.inc"
.include "monitor.inc"
; init the player's structures
.export player_init
; All the following functions returns the new player position:
; x in X and y in Y
; They may be unmodified ;)
; DESTROY A, X, Y, ZERO_2_1, ZERO_2_2
; Increments Player's X position
.export player_move_inx
; Increments Player's Y position
.export player_move_iny
; Decrements Player's X position
.export player_move_dex
; Decrements Player's Y position
.export player_move_dey
; Player coordinates in the maze ([0:255], [0:255])
.export Player_XY
.import compute_maze_addr
.BSS
Player_XY: .res 2
.CODE
; Player starts at [1:1]
player_init:
ldx #1
stx Player_XY
stx Player_XY+1
rts
; !!! ALL THE MOVE FUNCTION HAVE TO BE GROUPED TOGHETHER
; AS THERE IS A COMMON RETURN POINT TO WHICH THEY BRANHC (KEEP PC's DISTANCE < 127) !!!
.define ADDR_IN_MAZE ZERO_2_1
player_move_inx:
; check if moving is possible
ldx Player_XY
; test for border
cpx #WIDTH_MAZE - 1 ; last tile is always a wall...
beq return_from_player_move
; test that x+1 is "WALKABLE"
ldy Player_XY+1
jsr compute_maze_addr ; we get the adress for x,y then we increment x
stx ADDR_IN_MAZE
sta ADDR_IN_MAZE+1
ldy #1 ; will look at x+1
lda #ACTORS::WALKABLE
cmp (ADDR_IN_MAZE), Y
bcc return_from_player_move ; carry cleared if A is strictly the lesser --> not walkable
ldx Player_XY
inx
stx Player_XY ; walkable
bvc return_from_player_move
player_move_dex:
; check if moving is possible
ldx Player_XY
; test for border
cpx #1 ; 1st tile is always a wall...
beq return_from_player_move
; test that x+1 is "WALKABLE"
dex
ldy Player_XY+1
jsr compute_maze_addr ; we get the adress for x-1
stx ADDR_IN_MAZE
sta ADDR_IN_MAZE+1
ldy #0 ; will look at x-1
lda #ACTORS::WALKABLE
cmp (ADDR_IN_MAZE), Y
bcc return_from_player_move ; carry cleared if A is strictly the lesser --> not walkable
ldx Player_XY
dex
stx Player_XY ; walkable
bvc return_from_player_move
; Common code to return from the moves.
; Moves BRANCH to here
return_from_player_move:
; return player's coordinates
ldx Player_XY
ldy Player_XY+1
rts
player_move_iny:
; check if moving is possible
ldy Player_XY+1
; test for border
cpy #HEIGHT_MAZE - 1 ; last tile is always a wall...
beq return_from_player_move
; test that y+1 is "WALKABLE"
ldx Player_XY
iny
jsr compute_maze_addr ; we get the adress for x,y+1
stx ADDR_IN_MAZE
sta ADDR_IN_MAZE+1
ldy #0
lda #ACTORS::WALKABLE
cmp (ADDR_IN_MAZE), Y
bcc return_from_player_move ; carry cleared if A is strictly the lesser --> not walkable
ldy Player_XY+1 ; walkable
iny
sty Player_XY+1
bvc return_from_player_move
player_move_dey:
; check if moving is possible
ldy Player_XY+1
; test for border
cpy #1 ; 1st tile is always a wall...
beq return_from_player_move
; test that y-1 is "WALKABLE"
ldx Player_XY
dey
jsr compute_maze_addr ; we get the adress for x,y-1
stx ADDR_IN_MAZE
sta ADDR_IN_MAZE+1
ldy #0
lda #ACTORS::WALKABLE
cmp (ADDR_IN_MAZE), Y
bcc return_from_player_move ; carry cleared if A is strictly the lesser --> not walkable
ldy Player_XY+1 ; walkable
dey
sty Player_XY+1
bvc return_from_player_move
.undef ADDR_IN_MAZE

157
src/random.asm Normal file
View File

@ -0,0 +1,157 @@
; code copied form: http://6502.org/source/integers/random/random.html
; copyright Bruce Clark 2004
.include "memory.inc"
.export random8
.define TMP ZERO_2_1 ; requires 4 bytes
.define MOD ZERO_2_5
.CODE
;.align 256
; Linear congruential pseudo-random number generator
;
; Get the next SEED and obtain an 8-bit random number from it
;
; Requires the RAND subroutine
;
; Enter with:
;
; accumulator = modulus
;
; Exit with:
;
; accumulator = random number, 0 <= accumulator < modulus
;
; MOD, TMP, TMP+1, and TMP+2 are overwritten
;
; Note that TMP to TMP+2 are only used after RAND is called.
;
random8: STA MOD ; store modulus in MOD
JSR RAND ; get next seed
LDA #0 ; multiply SEED by MOD
STA TMP+2
STA TMP+1
STA TMP
SEC
ROR MOD ; shift out modulus, shifting in a 1 (will loop 8 times)
R8A: BCC R8B ; branch if a zero was shifted out
CLC ; add SEED, keep upper 8 bits of product in accumulator
TAX
LDA TMP
ADC SEED0
STA TMP
LDA TMP+1
ADC SEED1
STA TMP+1
LDA TMP+2
ADC SEED2
STA TMP+2
TXA
ADC SEED3
R8B: ROR ; shift product right
ROR TMP+2
ROR TMP+1
ROR TMP
LSR MOD ; loop until all 8 bits of MOD have been shifted out
BNE R8A
RTS
; Linear congruential pseudo-random number generator
;
; Calculate SEED = 1664525 * SEED + 1
;
; Enter with:
;
; SEED0 = byte 0 of seed
; SEED1 = byte 1 of seed
; SEED2 = byte 2 of seed
; SEED3 = byte 3 of seed
;
; Returns:
;
; SEED0 = byte 0 of seed
; SEED1 = byte 1 of seed
; SEED2 = byte 2 of seed
; SEED3 = byte 3 of seed
;
; TMP, TMP+1, TMP+2 and TMP+3 are overwritten
;
; Assuming that (a) SEED0 to SEED3 and TMP+0 to TMP+3 are all located on page
; zero, and (b) none of the branches cross a page boundary:
;
; Space: 106 bytes
; Speed: JSR RAND takes 517 cycles
;
RAND: CLC ; copy SEED into TMP
LDA SEED0 ; and compute SEED = SEED * $10000 + SEED + 1
STA TMP
ADC #1
STA SEED0
LDA SEED1
STA TMP+1
ADC #0
STA SEED1
LDA SEED2
STA TMP+2
ADC TMP
STA SEED2
LDA SEED3
STA TMP+3
ADC TMP+1
STA SEED3
;
; Bit 7 of $00, $19, $66, and $0D is 0, so only 6 shifts are necessary
;
LDY #5
RAND1: ASL TMP ; shift TMP (old seed) left
ROL TMP+1
ROL TMP+2
ROL TMP+3
;
; Get X from the RAND4 table. When:
;
; X = $00, SEED = SEED + $10000 * TMP
; X = $01, SEED = SEED + $100 * TMP
; X = $FE, SEED = SEED + $10000 * TMP + TMP
; X = $FF, SEED = SEED + $100 * TMP + TMP
;
LDX RAND4,Y
BPL RAND2 ; branch if X = $00 or X = $01
CLC ; SEED = SEED + TMP
LDA SEED0
ADC TMP
STA SEED0
LDA SEED1
ADC TMP+1
STA SEED1
LDA SEED2
ADC TMP+2
STA SEED2
LDA SEED3
ADC TMP+3
STA SEED3
INX ; $FE -> $00, $FF -> $01
INX
RAND2: CLC
BEQ RAND3 ; if X = $00, SEED = SEED + TMP * $10000
LDA SEED1 ; SEED = SEED + TMP * $100
ADC TMP
STA SEED1
RAND3: LDA SEED2
ADC TMP,X
STA SEED2
LDA SEED3
ADC TMP+1,X
STA SEED3
DEY
BPL RAND1
RTS
RAND4: .byte $01,$01,$00,$FE,$FF,$01

7
src/random.inc Normal file
View File

@ -0,0 +1,7 @@
; Enter with:
; accumulator = modulus
;
; Exit with:
; accumulator = random number, 0 <= accumulator < modulus
.import random8

165
src/tiles.asm Normal file
View File

@ -0,0 +1,165 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
.export TILES
.SEGMENT "TILES"
.ALIGN 256
PLAYER:
.byte 85, 42, 85, 42
.byte 1, 120, 3, 0
.byte 1, 126, 15, 0
.byte 1, 102, 12, 0
.byte 1, 126, 15, 0
.byte 1, 30, 15, 24
.byte 1, 120, 3, 6
.byte 113, 103, 76, 1
.byte 49, 70, 48, 0
.byte 53, 94, 95, 43
.byte 112, 71, 64, 0
.byte 80, 65, 64, 0
.byte 16, 16, 66, 0
.byte 16, 16, 66, 0
.byte 16, 16, 66, 0
.byte 16, 20, 74, 0
FLOOR_BLACK:
.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_ORANGE:
.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_VIOLET:
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
.byte $55, $2A, $55, $2A
FLOOR_BLUE:
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
.byte $D5, $AA, $D5, $AA
WALL_1:
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
.byte $7F, $7F, $7F, $7F
WALL_2:
.byte 197, 138, 213, 168
.byte 197, 138, 213, 168
.byte 197, 138, 213, 168
.byte 0, 0, 0, 0
.byte 209, 162, 149, 170
.byte 209, 162, 149, 170
.byte 209, 162, 149, 170
.byte 209, 162, 149, 170
.byte 0, 0, 0, 0
.byte 213, 168, 197, 138
.byte 213, 168, 197, 138
.byte 213, 168, 197, 138
.byte 0, 0, 0, 0
.byte 209, 130, 213, 168
.byte 209, 138, 212, 168
.byte 0, 0, 0, 0
UNKNOWN:
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.byte $80, $80, $80, $80
.SEGMENT "DATA"
; DON"T FORGET TO UPDATE NB_TILES!!
TILES:
.word PLAYER, FLOOR_BLACK, FLOOR_ORANGE, FLOOR_VIOLET, FLOOR_BLUE, WALL_1, WALL_2, UNKNOWN

24
src/tiles.inc Normal file
View File

@ -0,0 +1,24 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
.import TILES
.define NB_TILES 8

195
src/world.asm Normal file
View File

@ -0,0 +1,195 @@
; Copyright (C) 2018 Christophe Meneboeuf <christophe@xtof.info>
;
; 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 <http://www.gnu.org/licenses/>.
.include "world.inc"
.include "tiles.inc"
.include "random.inc"
.include "math.inc"
.include "memory.inc"
.export World
; initializes the world
; DESTROYS A,X,Y, ZERO_2_1, ZERO_2_2, ZERO_2_3
.export world_init
; sets the player's position onto the Maze
; in: X = x coord in the maze
; in: Y = y coord in the maze
; out : X and Y as they where given
; DESTROYS A,X,Y, ZERO_2_1, ZERO_2_2, ZERO_2_4, ZERO_2_5
.export world_set_player
; Computes the adress corresponding to the coordinates in the maze
; in: X = x coord in the maze
; in: Y = y coord in the maze
; out: AX = Address corresponding to (x,y) in the World array
; DESTROYS A,X,Y, ZERO_2_1, ZERO_2_2, ZERO_2_3
.export compute_maze_addr
.define TILE_NR ZERO_2_1
.define COORD_X ZERO_2_1
.define COORD_Y ZERO_2_2
.define OFFSET ZERO_2_2
.BSS
; The tile where the player stands
.struct Tile_player_standing
addr .word ; adress of the location
actor .byte ; actor on the location tile
.endstruct
.CODE
world_init:
; Saving the first tile on which the player stands
; FIXME player could be standing anywhere on any type of floor
ldx #1
ldy #1
jsr compute_maze_addr
stx Tile_player_standing::addr
sta Tile_player_standing::addr+1
stx ZERO_2_1
sta ZERO_2_1+1
ldy #0
lda (ZERO_2_1), Y
sta Tile_player_standing::actor
rts
; sets the player's position onto the World
world_set_player:
stx ZERO_2_4
sty ZERO_2_5
; restore the previous tile
ldx Tile_player_standing::addr
lda Tile_player_standing::addr+1
stx ZERO_2_1
sta ZERO_2_1+1
ldy #0
lda Tile_player_standing::actor
sta (ZERO_2_1), Y
; save the next tile
ldx ZERO_2_4
ldy ZERO_2_5
jsr compute_maze_addr ; get's player's position address in memory
stx Tile_player_standing::addr
sta Tile_player_standing::addr+1
stx ZERO_2_1
sta ZERO_2_1+1
ldy #0
lda (ZERO_2_1), y
sta Tile_player_standing::actor
; sets the player on the tile
lda #ACTORS::PLAYER
sta (ZERO_2_1), y
; restore the given locations
ldx ZERO_2_4
ldy ZERO_2_5
rts
compute_maze_addr:
stx COORD_X
; offset due to Y coord
sty FAC1
lda #WIDTH_WORLD
sta FAC2
jsr mul8
tay ; high part of the mul
txa ; low part of the mul
; adding offset due to X
clc
adc COORD_X
sta OFFSET
tya
adc #0
sta OFFSET+1
; adding the offset to the address
lda #<World
clc
adc OFFSET
tax ; low part of address to be returned in X
lda #>World
adc OFFSET+1 ; high part of address to be returned in X
rts
.DATA
.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

33
src/world.inc Normal file
View File

@ -0,0 +1,33 @@
; The world contains a Maze, filled with Actors
; Actors can be static, such a a floor or a wall,
; dynamic such as a door
; or alive, such as a monster
.define WIDTH_MAZE 64
.define HEIGHT_MAZE 40
.define SIZE_BORDER 0
.define WIDTH_WORLD WIDTH_MAZE + 2*SIZE_BORDER
.define HEIGHT_WORLD HEIGHT_MAZE + 2*SIZE_BORDER
.enum ACTORS
PLAYER = 0
FLOOR_BLACK = 1
FLOOR_ORANGE
FLOOR_VIOLET
FLOOR_BLUE
WALKABLE = FLOOR_BLUE ; Player won't be allowed to go on anything > WALKABLE
NOT_WALKABLE
NOT_TRANSPARENT = NOT_WALKABLE
WALL_1 = NOT_WALKABLE
WALL_2
UNKNOWN
NB_ACTORS
.endenum