aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/example/Makefile4
-rw-r--r--src/example/gb.asm76
-rw-r--r--src/gbcpu.c18
-rw-r--r--src/gbout.c28
-rw-r--r--src/util.c6
-rw-r--r--src/util.h5
6 files changed, 104 insertions, 33 deletions
diff --git a/src/example/Makefile b/src/example/Makefile
index 906bb44..f83d006 100644
--- a/src/example/Makefile
+++ b/src/example/Makefile
@@ -20,7 +20,7 @@
# Makefile for examples
#
-ALL = spectrum.tap c64.t64 zx81.p gb.rom vcs.bin
+ALL = spectrum.tap c64.t64 zx81.p gb.gb vcs.bin
CASM = ../casm
all: $(ALL) $(CASM)
@@ -39,7 +39,7 @@ c64.t64: c64.asm $(CASM)
zx81.p: zx81.asm $(CASM)
$(CASM) zx81.asm
-gb.rom: gb.asm $(CASM)
+gb.gb: gb.asm $(CASM)
$(CASM) gb.asm
vcs.bin: vcs.asm $(CASM)
diff --git a/src/example/gb.asm b/src/example/gb.asm
index ddefadb..10381e9 100644
--- a/src/example/gb.asm
+++ b/src/example/gb.asm
@@ -4,7 +4,7 @@
option output-file,gb.gb
option output-format,gameboy
- option gameboy-irq,vbl,vbl_code
+ ;option gameboy-irq,vbl,vbl_code
VRAM equ $8000
SCRN equ $9800
@@ -20,13 +20,13 @@ READY equ $ff81
XPOS equ $ff82
VBLANK macro
-; push af
-;.wait
-; ldh a,(CURLINE)
-; cp 144
-; jr nz,wait
-;
-; pop af
+ push af
+.wait
+ ldh a,(CURLINE)
+ cp 144
+ jr nz,wait
+
+ pop af
endm
@@ -60,7 +60,7 @@ VBLANK macro
;
ld hl,VRAM
ld de,sprite
- ld a,16
+ ld c,16
VBLANK
@@ -68,16 +68,48 @@ VBLANK macro
ld a,(de)
ld (hl+),a
inc de
- dec a
+ dec c
jr nz,copy
ld a,1
ldh (READY),a
-.idle
ei
- halt
- nop
+
+ VBLANK
+
+ ; Set sprite numbers
+ ;
+ xor a
+ ld (OAM+2),a
+ ld (OAM+6),a
+ ld (OAM+10),a
+
+ ; Set sprite flags
+ ;
+ ld a,$80
+ ld (OAM+3),a
+ ld (OAM+7),a
+ ld (OAM+11),a
+
+.idle
+ VBLANK
+
+ ldh a,(XPOS)
+ inc a
+ ldh (XPOS),a
+
+ ld (OAM),a
+ ld (OAM+1),a
+
+ add 20
+ ld (OAM+4),a
+ ld (OAM+5),a
+
+ add 33
+ ld (OAM+8),a
+ ld (OAM+9),a
+
jr idle
vbl_code:
@@ -98,12 +130,14 @@ vbl_code:
reti
sprite:
- defb $ff,00
- defb $ff,00
- defb $ff,00
- defb $ff,00
- defb $ff,00
- defb $ff,00
- defb $ff,00
- defb $ff,00
+ defb $ff,$ff
+ defb $00,00
+ defb $ff,$ff
+ defb $00,00
+ defb $ff,$ff
+ defb $00,00
+ defb $ff,$ff
+ defb $00,00
+ defb $ff,$ff
+ defb $00,00
diff --git a/src/gbcpu.c b/src/gbcpu.c
index 9f33bf5..074bf82 100644
--- a/src/gbcpu.c
+++ b/src/gbcpu.c
@@ -765,6 +765,7 @@ static CommandStatus LD(const char *label, int argc, char *argv[],
if (Is16Bit(t1) && !IsMemory(t1) && r2 == VALUE)
{
PCWrite(register_bitmask[r1] << 4 | 0x01);
+ PCWriteWord(off2);
return CMD_OK;
}
@@ -1810,6 +1811,21 @@ static CommandStatus RST(const char *label, int argc, char *argv[],
}
+static CommandStatus STOP(const char *label, int argc, char *argv[],
+ int quoted[], char *err, size_t errsize)
+{
+ if (argc == 1)
+ {
+ PCWrite(0x10);
+ PCWrite(0x00);
+ return CMD_OK;
+ }
+
+ return IllegalArgs(argc, argv, quoted, err, errsize);
+}
+
+
+
/* ---------------------------------------- OPCODE TABLES
*/
typedef struct
@@ -1856,6 +1872,7 @@ static const HandlerTable handler_table[] =
{"CALL", CALL},
{"RET", RET},
{"RST", RST},
+ {"STOP", STOP},
{NULL}
};
@@ -1876,7 +1893,6 @@ static const OpcodeTable implied_opcodes[] =
{"RLA", {0x17}},
{"RRA", {0x1f}},
{"RETI", {0xd9}},
- {"STOP", {0x10}},
{NULL}
};
diff --git a/src/gbout.c b/src/gbout.c
index 9b73655..24e365a 100644
--- a/src/gbout.c
+++ b/src/gbout.c
@@ -194,7 +194,7 @@ int GBOutput(const char *filename, const char *filename_bank,
int offset;
int rom_size;
unsigned global_csum = 0;
- Byte hdr_csum = 0;
+ unsigned hdr_csum = 0;
Byte *mem;
if (!fp)
@@ -318,6 +318,10 @@ int GBOutput(const char *filename, const char *filename_bank,
{
PokeB(mem, 0x146, 3);
}
+ else
+ {
+ PokeB(mem, 0x146, 0);
+ }
/* Type/ROM size
*/
@@ -353,7 +357,7 @@ int GBOutput(const char *filename, const char *filename_bank,
break;
}
- /* To be sold everywhere
+ /* Non-Japanese ROM
*/
PokeB(mem, 0x14a, 1);
@@ -361,18 +365,18 @@ int GBOutput(const char *filename, const char *filename_bank,
*/
if (option.is_super)
{
- PokeB(mem, 0x14a, 0x33);
+ PokeB(mem, 0x14b, 0x33);
}
else
{
- PokeB(mem, 0x14a, 0);
+ PokeB(mem, 0x14b, 0);
}
/* Header checksum
*/
for(f = 0x134 ; f < 0x14d; f++)
{
- hdr_csum -= mem[f];
+ hdr_csum -= mem[f] - 1;
}
PokeB(mem, 0x14d, hdr_csum);
@@ -381,18 +385,24 @@ int GBOutput(const char *filename, const char *filename_bank,
*/
if (count == 1)
{
- for(f = 0x150; f < 0x8000; f++)
+ for(f = 0; f < 0x8000; f++)
{
- global_csum += mem[f];
+ if (f < 0x14e || f > 0x14f)
+ {
+ global_csum += mem[f];
+ }
}
}
else
{
int r;
- for(f = 0x150; f < 0x4000; f++)
+ for(f = 0; f < 0x4000; f++)
{
- global_csum += mem[f];
+ if (f < 0x14e || f > 0x14f)
+ {
+ global_csum += mem[f];
+ }
}
for(r = 1; r < count; r++)
diff --git a/src/util.c b/src/util.c
index fd4bd10..0068540 100644
--- a/src/util.c
+++ b/src/util.c
@@ -196,6 +196,12 @@ int IsNullOrEmpty(const char *p)
return empty;
}
+
+void DebugBreakPoint(void)
+{
+ return;
+}
+
/*
vim: ai sw=4 ts=8 expandtab
*/
diff --git a/src/util.h b/src/util.h
index 3af1663..7222dce 100644
--- a/src/util.h
+++ b/src/util.h
@@ -87,6 +87,11 @@ char *CopyStr(char *dest, const char *src, size_t size);
int IsNullOrEmpty(const char *p);
+/* Null function that can be used as a handy place to hang a breakpoint.
+*/
+void DebugBreakPoint(void);
+
+
#endif
/*