Compare commits

..

10 Commits

Author SHA1 Message Date
d96588ec2d deleted old build batch file 2021-12-01 11:14:23 +01:00
b223361e54 added makefile 2021-12-01 11:02:07 +01:00
9c0346bc61 use screen size constants directly... 2021-11-30 23:21:47 +01:00
bab32fa68d moar comments, moar constants 2021-11-30 22:58:01 +01:00
0a2eef8336 use constants in edit code 2021-11-30 15:14:23 +01:00
fde5c95442 use automata and hardware constants in render 2021-11-29 17:20:29 +01:00
a2c8c40aaf added bug to todo 2021-11-29 17:04:50 +01:00
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
13 changed files with 76 additions and 58 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
Build
rom.sym
*.sym

View File

@@ -1,5 +1,7 @@
INCLUDE "hardware.inc"
BUFFER_SIZE = SCRN_X_B * SCRN_Y_B
; automata buffers with 4 cells per byte
; 2x2 bytes per cell, bit ordering:
; ___ ___
@@ -9,11 +11,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 +158,19 @@ SECTION "Update Automata", ROM0
UpdateAutomata:
.topleft
; handle top left corner
ConwayGroup 1, 21, 20, 39, 19, 359, 340, 341
ConwayGroup 1, (SCRN_X_B + 1), SCRN_X_B, (2 * SCRN_X_B - 1), (SCRN_X_B - 1), (BUFFER_SIZE - 1), (BUFFER_SIZE - SCRN_X_B), (BUFFER_SIZE - SCRN_X_B + 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, (SCRN_X_B - 2)
.top
ld [XLoop], a
; handle top row cell
ConwayGroup 1, 21, 20, 19, -1, 339, 340, 341
ConwayGroup 1, (SCRN_X_B + 1), SCRN_X_B, (SCRN_X_B - 1), -1, (BUFFER_SIZE - SCRN_X_B - 1), (BUFFER_SIZE - SCRN_X_B), (BUFFER_SIZE - SCRN_X_B + 1)
; advance to next cell in top row
ld hl, Progress
@@ -181,18 +183,18 @@ UpdateAutomata:
; handle top right corner
.topright
ConwayGroup -19, 1, 20, 19, -1, 339, 340, 321
ConwayGroup (-SCRN_X_B + 1), 1, SCRN_X_B, (SCRN_X_B - 1), -1, (BUFFER_SIZE - SCRN_X_B - 1), (BUFFER_SIZE - SCRN_X_B), (BUFFER_SIZE - 2 * SCRN_X_B + 1)
; advance pointers to next row
ld hl, Progress
inc [hl]
ld a, 16
ld a, (SCRN_Y_B - 2)
.leftcolumn
ld [YLoop], a
; handle first element in row
ConwayGroup 1, 21, 20, 39, 19, -1, -20, -19
ConwayGroup 1, (SCRN_X_B + 1), SCRN_X_B, (2 * SCRN_X_B - 1), (SCRN_X_B - 1), -1, (-SCRN_X_B), (-SCRN_X_B + 1)
; advance to next cell
ld hl, Progress
@@ -203,7 +205,7 @@ UpdateAutomata:
ld [XLoop], a
; handle element inside row
ConwayGroup 1, 21, 20, 19, -1, -21, -20, -19
ConwayGroup 1, (SCRN_X_B + 1), SCRN_X_B, (SCRN_X_B - 1), -1, (-SCRN_X_B - 1), (-SCRN_X_B), (-SCRN_X_B + 1)
; advance to next cell
ld hl, Progress
@@ -222,7 +224,7 @@ UpdateAutomata:
; handle last element in row
.rightcolumn
ConwayGroup -19, 1, 20, 19, -1, -21, -20, -39
ConwayGroup (-SCRN_X_B + 1), 1, SCRN_X_B, (SCRN_X_B - 1), -1, (-SCRN_X_B - 1), -SCRN_X_B, (-2 * SCRN_X_B + 1)
; advance to next row
ld hl, Progress
@@ -235,19 +237,19 @@ UpdateAutomata:
; handle bottom left element
.bottomleft
ConwayGroup 1, -339, -340, -321, 19, -1, -20, -19
ConwayGroup 1, (-BUFFER_SIZE + SCRN_X_B + 1), (-BUFFER_SIZE + SCRN_X_B), (-BUFFER_SIZE + 2 * SCRN_X_B - 1), (SCRN_X_B - 1), -1, (-SCRN_X_B), (-SCRN_X_B + 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, SCRN_X_B - 2
.bottom
ld [XLoop], a
; handle top row cell
ConwayGroup 1, -339, -340, -341, -1, -21, -20, -19
ConwayGroup 1, (-BUFFER_SIZE + SCRN_X_B + 1), (-BUFFER_SIZE + SCRN_X_B), (-BUFFER_SIZE + SCRN_X_B - 1), -1, (-SCRN_X_B - 1), (-SCRN_X_B), (-SCRN_X_B + 1)
; advance to next cell in top row
ld hl, Progress
@@ -260,7 +262,7 @@ UpdateAutomata:
; handle last element
.bottomright
ConwayGroup -19, -359, -340, -341, -1, -21, -20, -39
ConwayGroup (-SCRN_X_B + 1), (-BUFFER_SIZE + 1), (-BUFFER_SIZE + SCRN_X_B), (-BUFFER_SIZE + SCRN_X_B - 1), -1, (-SCRN_X_B - 1), (-SCRN_X_B), (-2 * SCRN_X_B + 1)
; move buffer address back to beginning
ld hl, Old
@@ -306,4 +308,4 @@ InitAutomata:
ldh [Rendered], a
ldh [Video], a
ret
ret

View File

@@ -23,7 +23,7 @@ BitsSet:
EXPORT DefaultMap
SECTION "Default Map", ROM0, ALIGN[8]
DefaultMap:
; 32x18 map matching the startup nintendo logo
; 32x18 game of life map matching the startup nintendo logo
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
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
@@ -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

@@ -16,9 +16,9 @@ SpriteDelay: ds 1
EXPORT InitEdit
SECTION "Init edit", ROM0
InitEdit:
ld a, 20
ld a, SCRN_X_B
ldh [SelectX], a
ld a, 18
ld a, SCRN_Y_B
ldh [SelectY], a
xor a
ldh [Down], a
@@ -210,7 +210,7 @@ ToggleCell:
ldh a, [Video + 1]
xor a, %100
ld h, a
MoveToCell 32
MoveToCell SCRN_VX_B
; toggle bit
ld a, [hl]
@@ -222,7 +222,7 @@ ToggleCell:
ld l, a
ldh a, [Old]
ld h, a
MoveToCell 20
MoveToCell SCRN_X_B
; toggle bit
ld a, [hl]
@@ -271,7 +271,7 @@ Clear:
ld [Rendered + 1], a
; clear old buffer
ld bc, 20 * 18
ld bc, SCRN_X_B * SCRN_Y_B
ld d, 0
call MemorySet

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

@@ -44,7 +44,8 @@ Intro:
jr z, .setBGPalette
; fade bg palette
ld b, 8
FADE_DELAY = 8 ; frames
ld b, FADE_DELAY
.fadeDelay0
HaltAndClearInterrupts
dec b
@@ -53,7 +54,7 @@ Intro:
ld a, %11111100
ldh [rBGP], a
ld b, 8
ld b, FADE_DELAY
.fadeDelay1
HaltAndClearInterrupts
dec b
@@ -62,7 +63,7 @@ Intro:
ld a, %11111000
ldh [rBGP], a
ld b, 8
ld b, FADE_DELAY
.fadeDelay2
HaltAndClearInterrupts
dec b
@@ -127,7 +128,7 @@ Intro:
ld a, LCDCF_ON | LCDCF_BGON | LCDCF_BG9800
ldh [rLCDC], a
; sound
; sweep sound while transforming nintendo logo into game of life of it
ld a, $77
ldh [rNR10], a ; sweep
ld a, (%00 << 6) + 0
@@ -146,22 +147,23 @@ FREQUENCY = 146
ld b, 20
.loopX
ld c, 2
; 3 frame delay
HaltAndClearInterrupts
HaltAndClearInterrupts
HaltAndClearInterrupts
.loopY
; copy 8 tiles (that's how many there is before L and E overflow)
; copy 8 tiles from (that's how many there is before L and E overflow)
REPT 8
ld a, [hl]
ld [de], a
ld a, l
add a, $20
add a, SCRN_VX_B
ld l, a
ld a, e
add a, $20
add a, SCRN_VX_B
ld e, a
ENDR
; L and E overflowed, we can increment H and L
; L and E overflowed, we can increment high byte of pointers (h and d)
inc h
inc d
dec c
@@ -171,10 +173,10 @@ REPT 2
ld a, [hl]
ld [de], a
ld a, l
add a, $20
add a, SCRN_VX_B
ld l, a
ld a, e
add a, $20
add a, SCRN_VX_B
ld e, a
ENDR
; back to beginning (high byte)
@@ -187,10 +189,10 @@ ENDR
; back to beginning + next column (low byte)
ld a, l
sub a, $3F
sub a, SCRN_VX_B * 2 - 1
ld l, a
ld a, e
sub a, $3F
sub a, SCRN_VX_B * 2 - 1
ld e, a
dec b

View File

@@ -75,9 +75,9 @@ ENDR
; copy default map into 20x18 automata buffer
ld hl, DefaultMap
ld de, Buffer0
ld c, 18
ld c, SCRN_Y_B
.loopY
ld b, 20
ld b, SCRN_X_B
.loopX
ld a, [hl+]
@@ -90,7 +90,7 @@ ENDR
jr z, .next
ld a, l
add a, 32 - 20
add a, SCRN_VX_B - SCRN_X_B
ld l, a
jr nc, .loopY

View File

@@ -71,7 +71,7 @@ LCDStatInterruptHandler:
; go to next line
ld a, e
add a, 32 - 20
add a, SCRN_VX_B - SCRN_X_B
ld e, a
jr nc, .nocarry
inc d
@@ -82,7 +82,7 @@ LCDStatInterruptHandler:
jr z, .finish
; reset tile counter
ld c, 20
ld c, SCRN_X_B
jr .loop
@@ -118,7 +118,7 @@ LCDStatInterruptHandler:
EXPORT InitRender
SECTION "Init render", ROM0
InitRender:
ld a, $9C
ld a, HIGH(_SCRN1)
ldh [Video + 1], a
xor a
ldh [Video], a
@@ -136,9 +136,9 @@ StartRender:
ld [Rendered + 1], a
; start rendering
ld a, 20
ld a, SCRN_X_B
ldh [TilesLeft], a
ld a, 18
ld a, SCRN_Y_B
ldh [LinesLeft], a
; enable v-blank and lcd stat interrupt for h-blank

Binary file not shown.

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

24
Makefile Normal file
View File

@@ -0,0 +1,24 @@
TITLE = "Game of Life"
INCLUDE = -i Graphics -i Code
NAME = $(notdir $(CURDIR))
FILES = $(wildcard Code/*.asm)
OBJECTS = $(patsubst Code/%.asm,Build/%.o,$(FILES))
.PHONY: clean mrproper
Build/%.o: Code/%.asm
@echo Assembling $<
@rgbasm $(INCLUDE) -o $@ $<
$(NAME).gb: $(OBJECTS)
@echo Linking...
@rgblink -n $(NAME).sym -w -t -o $(NAME).gb -d $(OBJECTS)
@rgbfix -t $(TITLE) -v -p 0 $(NAME).gb
clean:
@rm -f $(OBJECTS)
@rm -f $(NAME).sym
mrproper: clean
@rm -f $(NAME).gb

View File

@@ -1,10 +0,0 @@
..\..\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

View File

@@ -1,3 +1,4 @@
- music
- title screen
- cartridge!
- cartridge!
- fix frame lag while editing