Compare commits

...

3 Commits

Author SHA1 Message Date
78432f66d9 added constants to automata code, more readable 2021-11-29 16:56:41 +01:00
0cff33d046 assume rgbds is in PATH; updated source to new version 2021-11-29 16:07:34 +01:00
5d68584179 added real name to license file 2021-11-29 16:00:34 +01:00
5 changed files with 36 additions and 30 deletions

View File

@@ -1,5 +1,12 @@
INCLUDE "hardware.inc"
CELLS_WIDTH = 40
CELLS_HEIGHT = 36
CELLS_PER_TILE = 2
TILE_WIDTH = CELLS_WIDTH / CELLS_PER_TILE
TILE_HEIGHT = CELLS_HEIGHT / CELLS_PER_TILE
BUFFER_SIZE = TILE_WIDTH * TILE_HEIGHT
; automata buffers with 4 cells per byte
; 2x2 bytes per cell, bit ordering:
; ___ ___
@@ -9,11 +16,11 @@ INCLUDE "hardware.inc"
; bits 4, 5, 6 and 7 are not used
EXPORT Buffer0
SECTION "Automata buffer 0", WRAM0, ALIGN[9]
Buffer0: ds 20 * 18
Buffer0: ds BUFFER_SIZE
EXPORT Buffer1
SECTION "Automata buffer 1", WRAM0, ALIGN[9]
Buffer1: ds 20 * 18
Buffer1: ds BUFFER_SIZE
EXPORT New, Old, Progress
SECTION "Automata data", HRAM
@@ -156,19 +163,19 @@ SECTION "Update Automata", ROM0
UpdateAutomata:
.topleft
; handle top left corner
ConwayGroup 1, 21, 20, 39, 19, 359, 340, 341
ConwayGroup 1, (TILE_WIDTH + 1), TILE_WIDTH, (2 * TILE_WIDTH - 1), (TILE_WIDTH - 1), (BUFFER_SIZE - 1), (BUFFER_SIZE - TILE_WIDTH), (BUFFER_SIZE - TILE_WIDTH + 1)
; advance to next cell in top row
ld hl, Progress
inc [hl]
; handle all cells in top row except corners
ld a, 18
ld a, (TILE_WIDTH - 2)
.top
ld [XLoop], a
; handle top row cell
ConwayGroup 1, 21, 20, 19, -1, 339, 340, 341
ConwayGroup 1, (TILE_WIDTH + 1), TILE_WIDTH, (TILE_WIDTH - 1), -1, (BUFFER_SIZE - TILE_WIDTH - 1), (BUFFER_SIZE - TILE_WIDTH), (BUFFER_SIZE - TILE_WIDTH + 1)
; advance to next cell in top row
ld hl, Progress
@@ -181,18 +188,18 @@ UpdateAutomata:
; handle top right corner
.topright
ConwayGroup -19, 1, 20, 19, -1, 339, 340, 321
ConwayGroup (-TILE_WIDTH + 1), 1, TILE_WIDTH, (TILE_WIDTH - 1), -1, (BUFFER_SIZE - TILE_WIDTH - 1), (BUFFER_SIZE - TILE_WIDTH), (BUFFER_SIZE - 2 * TILE_WIDTH + 1)
; advance pointers to next row
ld hl, Progress
inc [hl]
ld a, 16
ld a, (TILE_HEIGHT - 2)
.leftcolumn
ld [YLoop], a
; handle first element in row
ConwayGroup 1, 21, 20, 39, 19, -1, -20, -19
ConwayGroup 1, (TILE_WIDTH + 1), TILE_WIDTH, (2 * TILE_WIDTH - 1), (TILE_WIDTH - 1), -1, (-TILE_WIDTH), (-TILE_WIDTH + 1)
; advance to next cell
ld hl, Progress
@@ -203,7 +210,7 @@ UpdateAutomata:
ld [XLoop], a
; handle element inside row
ConwayGroup 1, 21, 20, 19, -1, -21, -20, -19
ConwayGroup 1, (TILE_WIDTH + 1), TILE_WIDTH, (TILE_WIDTH - 1), -1, (-TILE_WIDTH - 1), (-TILE_WIDTH), (-TILE_WIDTH + 1)
; advance to next cell
ld hl, Progress
@@ -222,7 +229,7 @@ UpdateAutomata:
; handle last element in row
.rightcolumn
ConwayGroup -19, 1, 20, 19, -1, -21, -20, -39
ConwayGroup (-TILE_WIDTH + 1), 1, TILE_WIDTH, (TILE_WIDTH - 1), -1, (-TILE_WIDTH - 1), -TILE_WIDTH, (-2 * TILE_WIDTH + 1)
; advance to next row
ld hl, Progress
@@ -235,19 +242,19 @@ UpdateAutomata:
; handle bottom left element
.bottomleft
ConwayGroup 1, -339, -340, -321, 19, -1, -20, -19
ConwayGroup 1, (-BUFFER_SIZE + TILE_WIDTH + 1), (-BUFFER_SIZE + TILE_WIDTH), (-BUFFER_SIZE + 2 * TILE_WIDTH - 1), (TILE_WIDTH - 1), -1, (-TILE_WIDTH), (-TILE_WIDTH + 1)
; advance to next cell in bottom row
ld hl, Progress
inc [hl]
; handle all cells in bottom row except corners
ld a, 18
ld a, TILE_WIDTH - 2
.bottom
ld [XLoop], a
; handle top row cell
ConwayGroup 1, -339, -340, -341, -1, -21, -20, -19
ConwayGroup 1, (-BUFFER_SIZE + TILE_WIDTH + 1), (-BUFFER_SIZE + TILE_WIDTH), (-BUFFER_SIZE + TILE_WIDTH - 1), -1, (-TILE_WIDTH - 1), (-TILE_WIDTH), (-TILE_WIDTH + 1)
; advance to next cell in top row
ld hl, Progress
@@ -260,7 +267,7 @@ UpdateAutomata:
; handle last element
.bottomright
ConwayGroup -19, -359, -340, -341, -1, -21, -20, -39
ConwayGroup (-TILE_WIDTH + 1), (-BUFFER_SIZE + 1), (-BUFFER_SIZE + TILE_WIDTH), (-BUFFER_SIZE + TILE_WIDTH - 1), -1, (-TILE_WIDTH - 1), (-TILE_WIDTH), (-2 * TILE_WIDTH + 1)
; move buffer address back to beginning
ld hl, Old
@@ -306,4 +313,4 @@ InitAutomata:
ldh [Rendered], a
ldh [Video], a
ret
ret

View File

@@ -43,14 +43,13 @@ DefaultMap:
db 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
db 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
EXPORT BackgroundTiles, BackgroundTilesEnd
SECTION "Graphics", ROM0
EXPORT BackgroundTiles, BackgroundTilesEnd
BackgroundTiles:
INCBIN "BackgroundTiles.bin"
BackgroundTilesEnd: ds 0
EXPORT SpriteTiles, SpriteTilesEnd
SECTION "Graphics", ROM0
SpriteTiles:
INCBIN "SpriteTiles.bin"
SpriteTilesEnd: ds 0
SpriteTilesEnd: ds 0

View File

@@ -25,7 +25,7 @@
; If all of these are already defined, don't do it again.
IF !DEF(HARDWARE_INC)
HARDWARE_INC SET 1
HARDWARE_INC = 1
rev_Check_hardware_inc : MACRO
;NOTE: REVISION NUMBER CHANGES MUST BE ADDED

View File

@@ -1,6 +1,6 @@
BSD 3-Clause License
Copyright (c) 2018, MsK`
Copyright (c) 2018, Daniel Borges (MsK`)
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -1,10 +1,10 @@
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\main.o Code\main.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\data.o Code\data.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\automata.o Code\automata.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\render.o Code\render.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\utils.o Code\utils.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\intro.o Code\intro.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\edit.o Code\edit.asm
..\..\Assembler\rgbasm %* -i Graphics\ -i Code\ -o Build\joypad.o Code\joypad.asm
..\..\Assembler\rgblink -n rom.sym -w -t -o rom.gb -d Build/main.o Build/data.o Build/automata.o Build/render.o Build/utils.o Build/intro.o Build/edit.o Build/joypad.o
..\..\Assembler\rgbfix -t "Game of Life" -v -p 0 rom.gb
rgbasm -i Graphics -i Code -o Build/main.o Code/main.asm
rgbasm -i Graphics -i Code -o Build/data.o Code/data.asm
rgbasm -i Graphics -i Code -o Build/automata.o Code/automata.asm
rgbasm -i Graphics -i Code -o Build/render.o Code/render.asm
rgbasm -i Graphics -i Code -o Build/utils.o Code/utils.asm
rgbasm -i Graphics -i Code -o Build/intro.o Code/intro.asm
rgbasm -i Graphics -i Code -o Build/edit.o Code/edit.asm
rgbasm -i Graphics -i Code -o Build/joypad.o Code/joypad.asm
rgblink -n rom.sym -w -t -o rom.gb -d Build/main.o Build/data.o Build/automata.o Build/render.o Build/utils.o Build/intro.o Build/edit.o Build/joypad.o
rgbfix -t "Game of Life" -v -p 0 rom.gb