diff --git a/.gitignore b/.gitignore index 4904775..3d7bafa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ *.o tags *bkp* +output.map +/*.s diff --git a/incs/blast.h b/incs/blast.h index 5d00061..d86b4b6 100644 --- a/incs/blast.h +++ b/incs/blast.h @@ -4,6 +4,8 @@ #include "sprite.h" #include "u8_stack.h" #include "math_tables.h" +//#include "logic.h" +//#include "physics.h" #ifndef _BLAST #define _BLAST @@ -21,6 +23,7 @@ void hblank(); void blast_init(); void wait_vsync(); void BLAST_debugText(const char* inbuf, u16 x, u16 y); +void showFPS(VDPPlane plan, u16 float_display); /* u8 coll_col [40]; u8 coll_row [28]; diff --git a/incs/sprite.h b/incs/sprite.h index 5ff9590..374529a 100644 --- a/incs/sprite.h +++ b/incs/sprite.h @@ -6,7 +6,8 @@ //#include "tilemap.h" #define MAX_SPRITE 80 -#define SLIST 0xDC00 +//#define SLIST 0xF400 +#define SLIST slist_addr #define MAX_SPRITE_COL 2 #define MAX_SPRITE_ROW 2 diff --git a/incs/tilemap.h b/incs/tilemap.h index 0260cd7..abc9fa9 100644 --- a/incs/tilemap.h +++ b/incs/tilemap.h @@ -53,7 +53,7 @@ typedef struct d_map{ // Which plane are we using? //u16 plane; - VDPPlan plane; + VDPPlane plane; // tiles -> map of tiles tilemap* tiles; @@ -63,7 +63,7 @@ typedef struct d_map{ } blastmap; -void blastmap_init(blastmap* bmap, tilemap* tmap, u16* tlookup, u16 tileoffset, VDPPlan plane); +void blastmap_init(blastmap* bmap, tilemap* tmap, u16* tlookup, u16 tileoffset, VDPPlane plane); void load_map(blastmap* bmap, int xoffset, int yoffset); void load_visible_map(blastmap* bmap, int xoffset, int yoffset); void load_map_row(blastmap* bmap, u8 row); diff --git a/libs/blast.c b/libs/blast.c index f560cf9..14f24f8 100644 --- a/libs/blast.c +++ b/libs/blast.c @@ -4,10 +4,10 @@ char str[10]; void vblank() { - //VDP_setHorizontalScroll(PLAN_B,hscroll*4); - //VDP_setVerticalScroll(PLAN_B,vScroll*4); - VDP_setHorizontalScroll(PLAN_A,hs); - VDP_setVerticalScroll(PLAN_A,vs); + //VDP_setHorizontalScroll(BG_B,hscroll*4); + //VDP_setVerticalScroll(BG_B,vScroll*4); + VDP_setHorizontalScroll(BG_A,hs); + VDP_setVerticalScroll(BG_A,vs); //VDP_updateSprites(1,FALSE); BLAST_updateSprites(); @@ -45,7 +45,7 @@ void blast_init() { //VDP_resetSprites(); //VDP_setScreenWidth256(); - //VDP_setScreenWidth320(); + VDP_setScreenWidth320(); //VDP_setHIntCounter(2); //VDP_setHInterrupt(1); @@ -53,13 +53,13 @@ void blast_init() { //VDP_setPlanSize(64,64); VDP_setScrollingMode(HSCROLL_PLANE, VSCROLL_PLANE); - //VDP_setTextPalette(1); - //VDP_clearPlan(VDP_PLAN_A, 0); + VDP_setTextPalette(1); + //VDP_clearPlan(VDP_BG_A, 0); - //VDP_clearPlan(PLAN_A, 0); - //VDP_clearPlan(PLAN_B, 0); + VDP_clearPlane(BG_A, 0); + VDP_clearPlane(BG_B, 0); - //VDP_clearPlan(VDP_PLAN_B, 0); + //VDP_clearPlan(VDP_BG_B, 0); SYS_setVIntCallback(vblank); @@ -96,3 +96,25 @@ void BLAST_debugText(const char* inbuf, u16 x, u16 y) { SYS_enableInts(); #endif } + +void showFPS(VDPPlane plan, u16 float_display) +{ + char str[16]; + SYS_disableInts(); + if (float_display) + { + fix32ToStr(getFPS_f(), str, 1); + VDP_clearText(2, 1, 5); + } + else + { + uintToStr(getFPS(), str, 1); + VDP_clearText(2, 1, 2); + } + + // display FPS + VDP_drawTextBG(plan," ",1,1); + VDP_drawTextBG(plan,str,1,1); + SYS_enableInts(); +} + diff --git a/libs/gfx.c b/libs/gfx.c index d36ec46..f60a179 100644 --- a/libs/gfx.c +++ b/libs/gfx.c @@ -5,7 +5,7 @@ static u16 vdp_offset = TILE_USERINDEX; u16 draw_img(Image *img) { u16 tmp_offset = vdp_offset; - VDP_drawImageEx(PLAN_B, img, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, vdp_offset), 0, 0, FALSE, TRUE); + VDP_drawImageEx(BG_B, img, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, vdp_offset), 0, 0, FALSE, TRUE); vdp_offset += img->tileset->numTile; return tmp_offset; } diff --git a/libs/sprite.c b/libs/sprite.c index 24767ad..33ab761 100644 --- a/libs/sprite.c +++ b/libs/sprite.c @@ -61,7 +61,7 @@ void BLAST_updateSprites() next_idx = sprite->link; - //uintToStr(sprite->link, abuf, 3); + //uintToStr(sprite->posy, abuf, 3); //VDP_drawText(abuf, 5, 7+i); if(next_idx == 0) @@ -857,7 +857,7 @@ void vscroll_sprites(s8 vscroll) while(1) { - //VDP_drawTextBG(VDP_PLAN_A, "SCROLL", 0x8000, 4,4); + //VDP_drawTextBG(VDP_BG_A, "SCROLL", 0x8000, 4,4); // If the next link is 0, we are at the end tsprite = _sprite_all[cur_idx]; diff --git a/libs/tilemap.c b/libs/tilemap.c index d71201d..80cd996 100644 --- a/libs/tilemap.c +++ b/libs/tilemap.c @@ -1,15 +1,15 @@ #include "genesis.h" #include "blast.h" -void blastmap_init(blastmap* bmap, tilemap* tmap, u16* tlookup, u16 tileoffset, VDPPlan plane) { +void blastmap_init(blastmap* bmap, tilemap* tmap, u16* tlookup, u16 tileoffset, VDPPlane plane) { bmap->tX = 64; bmap->tY = 64; bmap->winX = bmap->tX; bmap->winY = bmap->tY; bmap->maph = 0; bmap->mapw = 0; - bmap->planwidth = VDP_getPlanWidth(); - bmap->planheight = VDP_getPlanHeight(); + bmap->planwidth = VDP_getPlaneWidth(); + bmap->planheight = VDP_getPlaneHeight(); bmap->tileoffset = tileoffset; bmap->plane = plane; bmap->tiles = tmap; @@ -495,7 +495,9 @@ void load_map_row(blastmap* bmap, u8 row) { j, i, numtiles_a, - 1 + 1, + 1, + CPU ); VDP_setTileMapDataRect( bmap->plane, @@ -503,7 +505,9 @@ void load_map_row(blastmap* bmap, u8 row) { 0, i, numtiles_b, - 1 + 1, + 1, + CPU ); } else { @@ -515,7 +519,9 @@ void load_map_row(blastmap* bmap, u8 row) { j, i, numtiles, - 1 + 1, + 1, + CPU ); } @@ -598,7 +604,9 @@ void load_map_col(blastmap* bmap, u8 col) { i, j, 1, - numtiles_a + numtiles_a, + 1, + CPU ); VDP_setTileMapDataRect( bmap->plane, @@ -606,7 +614,9 @@ void load_map_col(blastmap* bmap, u8 col) { i, 0, 1, - numtiles_b + numtiles_b, + 1, + CPU ); } else { // Does this handle plane wrap around? NOPE @@ -616,7 +626,9 @@ void load_map_col(blastmap* bmap, u8 col) { i, j, 1, - numtiles + numtiles, + 1, + CPU ); } SYS_enableInts(); diff --git a/mkfiles/Makefile.sgdk1_51 b/mkfiles/Makefile.sgdk1_51 new file mode 100644 index 0000000..0e5607c --- /dev/null +++ b/mkfiles/Makefile.sgdk1_51 @@ -0,0 +1,224 @@ +GENDEV?=/opt/gendev/ +GCC_VER?=6.3.0 + +MAKE?=make +LIB?=lib +GENGCC_BIN=$(GENDEV)/bin +GENBIN=$(GENDEV)/bin +SGDK_VER=v1.51 + +-include proj.mk + +CC = $(GENGCC_BIN)/m68k-elf-gcc +AS = $(GENGCC_BIN)/m68k-elf-as +AR = $(GENGCC_BIN)/m68k-elf-ar +LD = $(GENGCC_BIN)/m68k-elf-ld +RANLIB = $(GENGCC_BIN)/m68k-elf-ranlib +OBJC = $(GENGCC_BIN)/m68k-elf-objcopy +BINTOS = $(GENBIN)/bintos +#RESCOMP= $(GENBIN)/rescomp +RESCOMP = java -jar $(GENBIN)/rescomp.jar +XGMTOOL= $(GENBIN)/xgmtool +PCMTORAW = $(GENBIN)/pcmtoraw +WAVTORAW = $(GENBIN)/wavtoraw +SIZEBND = $(GENBIN)/sizebnd +ASMZ80 = $(GENBIN)/zasm +TILED2C = python3 ../../tools/tiled2c.py + +RM = rm -f +NM = nm +NM2WCH = nm2wch +MKISOFS = mkisofs + +SCD_LOADER = scd/LukeProjectCD + +OPTION = +#OPTION = -save-temps +#INCS = -I. -I$(GENDEV)/m68k-elf/include -I$(GENDEV)/m68k-elf/include -Isrc -Ires +INCS = -I$(GENDEV)/include/blast -I. -I $(GENDEV)/sgdk$(SGDK_VER)/res -I $(GENDEV)/sgdk$(SGDK_VER)/inc -I$(GENDEV)/m68k-elf/include -I$(GENDEV)/m68k-elf/m68k-elf/include -Isrc -Ires +#INCS = -I. -I $(GENDEV)/sgdk$(SGDK_VER)/res -I $(GENDEV)/sgdk$(SGDK_VER)/inc -I$(GENDEV)/m68k-elf/include -I$(GENDEV)/m68k-elf/m68k-elf/include -Isrc -Ires +CCFLAGS = $(OPTION) -m68000 -Wall -O2 -c -fomit-frame-pointer +HWCCFLAGS = $(OPTION) -m68000 -Wall -O1 -c -fomit-frame-pointer +Z80FLAGS = -vb2 +ASFLAGS = -m68000 --register-prefix-optional +#LIBS = -L$(GENDEV)/m68k-elf/lib -L$(GENDEV)/m68k-elf/lib/gcc/m68k-elf/4.8.2 -L$(GENDEV)/m68k-elf/m68k-elf/lib -lmd -lc -lgcc -lnosys -lm +#LIBS = -L$(GENDEV)/m68k-elf/lib -L$(GENDEV)/sgdk$(SGDK_VER)/lib -lmd -lnosys -lblast + +#LIBS = -L$(GENDEV)/m68k-elf/lib -L$(GENDEV)/sgdk$(SGDK_VER)/lib -lmd -lnosys -lblast + +LIBS = -L$(GENDEV)/m68k-elf/lib -L$(GENDEV)/sgdk$(SGDK_VER)/lib -lmd -lblast +#LINKFLAGS = -T $(GENDEV)/ldscripts/md.ld -Map=output.map -nostdlib +LINKFLAGS = -T $(GENDEV)/sgdk$(SGDK_VER)/md.ld -Map=output.map -nostdlib +SCDLINKFLAGS = -T scd/mdcd.ld -nostdlib +ARCHIVES = $(GENDEV)/sgdk$(SGDK_VER)/lib/libmd.a + + +# Are we AMD64? +#LBITS := $(shell getconf LONG_BIT) +#ifeq ($(LBITS), 64) +#ARCHIVES += $(GENDEV)/m68k-elf/lib64/gcc/m68k-elf/$(GCC_VER)/libgcc.a +#else +#ARCHIVES += $(GENDEV)/m68k-elf/lib/gcc/m68k-elf/$(GCC_VER)/libgcc.a +#endif + +ARCHIVES += $(GENDEV)/$(LIB)/gcc/m68k-elf/$(GCC_VER)/libgcc.a +ARCHIVES += $(GENDEV)/m68k-elf/lib/libblast.a + +RESOURCES= +BOOT_RESOURCES= + +BOOTSS=$(wildcard boot/*.s) +BOOTSS+=$(wildcard src/boot/*.s) +BOOT_RESOURCES+=$(BOOTSS:.s=.o) + +SCDBOOTSS=$(wildcard scd/*.s) +SCDBOOTSS+=$(wildcard src/scd/*.s) +SCDBOOT_RESOURCES=$(SCDBOOTSS:.s=.o) + +#BMPS=$(wildcard res/*.bmp) +#VGMS=$(wildcard res/*.vgm) +#RAWS=$(wildcard res/*.raw) +#PCMS=$(wildcard res/*.pcm) +#MVSS=$(wildcard res/*.mvs) +#TFDS=$(wildcard res/*.tfd) +#WAVS=$(wildcard res/*.wav) +TMXS=$(wildcard res/*.tmx) +RESS=$(wildcard res/*.res) +#WAVPCMS=$(wildcard res/*.wavpcm) +#BMPS+=$(wildcard *.bmp) +#VGMS+=$(wildcard *.vgm) +#RAWS+=$(wildcard *.raw) +#PCMS+=$(wildcard *.pcm) +#MVSS+=$(wildcard *.mvs) +#TFDS+=$(wildcard *.tfd) +#WAVS+=$(wildcard *.wav) +RESS+=$(wildcard *.res) +#WAVPCMS+=$(wildcard *.wavpcm) + +#RESOURCES+=$(BMPS:.bmp=.o) +#RESOURCES+=$(VGMS:.vgm=.o) +#RESOURCES+=$(RAWS:.raw=.o) +#RESOURCES+=$(PCMS:.pcm=.o) +#RESOURCES+=$(MVSS:.mvs=.o) +#RESOURCES+=$(TFDS:.tfd=.o) +#RESOURCES+=$(WAVS:.wav=.o) +#RESOURCES+=$(WAVPCMS:.wavpcm=.o) +RESOURCES+=$(RESS:.res=.o) + +HEADERS=$(TMXS:.tmx=.h) + +CS=$(wildcard src/*.c) +SS=$(wildcard src/*.s) +S80S=$(wildcard src/*.s80) +CS+=$(wildcard *.c) +SS+=$(wildcard *.s) +S80S+=$(wildcard *.s80) +RESOURCES+=$(CS:.c=.o) +RESOURCES+=$(SS:.s=.o) +RESOURCES+=$(S80S:.s80=.o) + +OBJS = $(RESOURCES) + +all: out.bin + +boot/sega.o: boot/rom_head.bin + $(AS) $(ASFLAGS) boot/sega.s -o $@ + +scd/segacd.o: + $(AS) $(ASFLAGS) scd/segacd.s -o $@ + + +out.iso: out.elf_scd + # + # Create a sega cd image. Limited to 256K or smaller Roms + # + $(NM) -n -S -t x out.elf_scd > out.nm + $(OBJC) -O binary out.elf_scd out.bin + $(SIZEBND) out.bin -sizealign 131072 + $(OBJC) -O binary out.elf_scd $(SCD_LOADER)/_filesystem/M_INIT.PRG + $(SIZEBND) $(SCD_LOADER)/_filesystem/M_INIT.PRG -sizealign 131072 + $(MKISOFS) -iso-level 1 -o $(SCD_LOADER)/filesystem.img -pad $(SCD_LOADER)/_filesystem + tail -c +32769 $(SCD_LOADER)/filesystem.img > $(SCD_LOADER)/filesystem.bin + $(RM) -f $(SCD_LOADER)/filesystem.img + cd $(SCD_LOADER) && $(AS) $(ASFLAGS) -M -ahlsm=listing.asm main-us-as.asm -o out.iso + tail -c +53 $(SCD_LOADER)/out.iso > out.iso + $(RM) -f $(SCD_LOADER)/filesystem.bin + +%.bin: %.elf + $(OBJC) -O binary $< temp.bin + dd if=temp.bin of=$@ bs=8K conv=sync + +%.elf: $(OBJS) $(BOOT_RESOURCES) + $(LD) -o $@ $(LINKFLAGS) $(BOOT_RESOURCES) $(ARCHIVES) $(OBJS) $(LIBS) + +%.elf_scd: $(OBJS) $(SCDBOOT_RESOURCES) + $(LD) -o $@ $(SCDLINKFLAGS) $(SCDBOOT_RESOURCES) $(ARCHIVES) $(OBJS) $(LIBS) + +%.o80: %.s80 + $(ASMZ80) $(Z80FLAGS) -o $@ $< + +%.c: %.o80 + $(BINTOS) $< + +%.o: %.c + $(CC) $(CCFLAGS) $(INCS) -c $< -o $@ + +%.o: %.s + $(AS) $(ASFLAGS) $< -o $@ + +%.s: %.bmp + bintos -bmp $< + +%.rawpcm: %.pcm + $(PCMTORAW) $< $@ + +%.raw: %.wav + $(WAVTORAW) $< $@ 16000 + +%.pcm: %.wavpcm + $(WAVTORAW) $< $@ 22050 + +#%.tfc: %.tfd +# $(TFMCOM) $< + +#%.o80: %.s80 +# $(ASMZ80) $(FLAGSZ80) $< $@ out.lst + +%.s: %.tfd + $(BINTOS) -align 32768 $< + +%.s: %.mvs + $(BINTOS) -align 256 $< + +%.s: %.esf + $(BINTOS) -align 32768 $< + +%.s: %.eif + $(BINTOS) -align 256 $< + +%.s: %.vgm + $(BINTOS) -align 256 $< + +%.s: %.raw + $(BINTOS) -align 256 -sizealign 256 $< + +%.s: %.rawpcm + $(BINTOS) -align 128 -sizealign 128 -nullfill 136 $< + +%.s: %.rawpcm + $(BINTOS) -align 128 -sizealign 128 -nullfill 136 $< + +%.s: %.res $(HEADERS) + $(RESCOMP) $< $@ + +%.h: %.tmx + $(TILED2C) $< $@ + +boot/rom_head.bin: boot/rom_head.o + $(LD) $(LINKFLAGS) --oformat binary -o $@ $< + + +clean: + $(RM) $(RESOURCES) + $(RM) *.o *.bin *.elf *.elf_scd *.map *.iso + $(RM) boot/*.o boot/*.bin diff --git a/tests/hello_world/Makefile b/tests/hello_world/Makefile new file mode 120000 index 0000000..6954742 --- /dev/null +++ b/tests/hello_world/Makefile @@ -0,0 +1 @@ +../../mkfiles/Makefile.sgdk1_51 \ No newline at end of file diff --git a/tests/hello_world/boot/rom_head.c b/tests/hello_world/boot/rom_head.c new file mode 100644 index 0000000..451564b --- /dev/null +++ b/tests/hello_world/boot/rom_head.c @@ -0,0 +1,43 @@ +#include "types.h" + + +const struct +{ + char console[16]; /* Console Name (16) */ + char copyright[16]; /* Copyright Information (16) */ + char title_local[48]; /* Domestic Name (48) */ + char title_int[48]; /* Overseas Name (48) */ + char serial[14]; /* Serial Number (2, 12) */ + u16 checksum; /* Checksum (2) */ + char IOSupport[16]; /* I/O Support (16) */ + u32 rom_start; /* ROM Start Address (4) */ + u32 rom_end; /* ROM End Address (4) */ + u32 ram_start; /* Start of Backup RAM (4) */ + u32 ram_end; /* End of Backup RAM (4) */ + char sram_sig[2]; /* "RA" for save ram (2) */ + u16 sram_type; /* 0xF820 for save ram on odd bytes (2) */ + u32 sram_start; /* SRAM start address - normally 0x200001 (4) */ + u32 sram_end; /* SRAM end address - start + 2*sram_size (4) */ + char modem_support[12]; /* Modem Support (24) */ + char notes[40]; /* Memo (40) */ + char region[16]; /* Country Support (16) */ +} rom_header = { + "SEGA MEGA DRIVE ", + "(C)FLEMTEAM 2013", + "SAMPLE PROGRAM ", + "SAMPLE PROGRAM ", + "GM 00000000-00", + 0x0000, + "JD ", + 0x00000000, + 0x00100000, + 0x00FF0000, + 0x00FFFFFF, + " ", + 0x0000, + 0x00200000, + 0x002001FF, + " ", + "DEMONSTRATION PROGRAM ", + "JUE " +}; diff --git a/tests/hello_world/boot/sega.s b/tests/hello_world/boot/sega.s new file mode 100644 index 0000000..9c98070 --- /dev/null +++ b/tests/hello_world/boot/sega.s @@ -0,0 +1,469 @@ +.section .text.keepboot + +*------------------------------------------------------- +* +* Sega startup code for the GNU Assembler +* Translated from: +* Sega startup code for the Sozobon C compiler +* Written by Paul W. Lee +* Modified by Charles Coty +* Modified by Stephane Dallongeville +* +*------------------------------------------------------- + + .org 0x00000000 + +_Start_Of_Rom: +_Vecteurs_68K: + dc.l 0x00FFFE00 /* Stack address */ + dc.l _Entry_Point /* Program start address */ + dc.l _Bus_Error + dc.l _Address_Error + dc.l _Illegal_Instruction + dc.l _Zero_Divide + dc.l _Chk_Instruction + dc.l _Trapv_Instruction + dc.l _Privilege_Violation + dc.l _Trace + dc.l _Line_1010_Emulation + dc.l _Line_1111_Emulation + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _INT, _EXTINT, _INT + dc.l _HINT + dc.l _INT + dc.l _VINT + dc.l _INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + + .incbin "boot/rom_head.bin", 0x10, 0x100 + +_Entry_Point: + move #0x2700,%sr + tst.l 0xa10008 + bne.s SkipJoyDetect + tst.w 0xa1000c +SkipJoyDetect: + bne.s SkipSetup + + lea Table,%a5 + movem.w (%a5)+,%d5-%d7 + movem.l (%a5)+,%a0-%a4 +* Check Version Number + move.b -0x10ff(%a1),%d0 + andi.b #0x0f,%d0 + beq.s WrongVersion +* Sega Security Code (SEGA) + move.l #0x53454741,0x2f00(%a1) +WrongVersion: + move.w (%a4),%d0 + moveq #0x00,%d0 + movea.l %d0,%a6 + move %a6,%usp + move.w %d7,(%a1) + move.w %d7,(%a2) + jmp Continue + +Table: + dc.w 0x8000,0x3fff,0x0100 + dc.l 0xA00000,0xA11100,0xA11200,0xC00000,0xC00004 + +SkipSetup: + move.w #0,%a7 + jmp _reset_entry + +Continue: + +* clear Genesis RAM + lea 0xff0000,%a0 + moveq #0,%d0 + move.w #0x3FFF,%d1 + +ClearRam: + move.l %d0,(%a0)+ + dbra %d1,ClearRam + +* copy initialized variables from ROM to Work RAM + lea _stext,%a0 + lea 0xFF0000,%a1 + move.l #_sdata,%d0 + lsr.l #1,%d0 + beq NoCopy + + subq.w #1,%d0 +CopyVar: + move.w (%a0)+,(%a1)+ + dbra %d0,CopyVar + +NoCopy: + +* Jump to initialisation process... + + move.w #0,%a7 + jmp _start_entry + + +*------------------------------------------------ +* +* interrupt functions +* +*------------------------------------------------ + +registersDump: + move.l %d0,registerState+0 + move.l %d1,registerState+4 + move.l %d2,registerState+8 + move.l %d3,registerState+12 + move.l %d4,registerState+16 + move.l %d5,registerState+20 + move.l %d6,registerState+24 + move.l %d7,registerState+28 + move.l %a0,registerState+32 + move.l %a1,registerState+36 + move.l %a2,registerState+40 + move.l %a3,registerState+44 + move.l %a4,registerState+48 + move.l %a5,registerState+52 + move.l %a6,registerState+56 + move.l %a7,registerState+60 + rts + +busAddressErrorDump: + move.w 4(%sp),ext1State + move.l 6(%sp),addrState + move.w 10(%sp),ext2State + move.w 12(%sp),srState + move.l 14(%sp),pcState + jmp registersDump + +exception4WDump: + move.w 4(%sp),srState + move.l 6(%sp),pcState + move.w 10(%sp),ext1State + jmp registersDump + +exceptionDump: + move.w 4(%sp),srState + move.l 6(%sp),pcState + jmp registersDump + + +_Bus_Error: + jsr busAddressErrorDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l busErrorCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Address_Error: + jsr busAddressErrorDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l addressErrorCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Illegal_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l illegalInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Zero_Divide: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l zeroDivideCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Chk_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l chkInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Trapv_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l trapvInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Privilege_Violation: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l privilegeViolationCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Trace: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l traceCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Line_1010_Emulation: +_Line_1111_Emulation: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l line1x1xCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Error_Exception: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l errorExceptionCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_INT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l intCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_EXTINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalExtIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_HINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalHIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_VINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalVIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +*------------------------------------------------ +* +* Copyright (c) 1988 by Sozobon, Limited. Author: Johann Ruegg +* +* Permission is granted to anyone to use this software for any purpose +* on any computer system, and to redistribute it freely, with the +* following restrictions: +* 1) No charge may be made other than reasonable charges for reproduction. +* 2) Modified versions must be clearly marked as such. +* 3) The authors are not responsible for any harmful consequences +* of using this software, even if they result from defects in it. +* +*------------------------------------------------ + +ldiv: + move.l 4(%a7),%d0 + bpl ld1 + neg.l %d0 +ld1: + move.l 8(%a7),%d1 + bpl ld2 + neg.l %d1 + eor.b #0x80,4(%a7) +ld2: + bsr i_ldiv /* d0 = d0/d1 */ + tst.b 4(%a7) + bpl ld3 + neg.l %d0 +ld3: + rts + +lmul: + move.l 4(%a7),%d0 + bpl lm1 + neg.l %d0 +lm1: + move.l 8(%a7),%d1 + bpl lm2 + neg.l %d1 + eor.b #0x80,4(%a7) +lm2: + bsr i_lmul /* d0 = d0*d1 */ + tst.b 4(%a7) + bpl lm3 + neg.l %d0 +lm3: + rts + +lrem: + move.l 4(%a7),%d0 + bpl lr1 + neg.l %d0 +lr1: + move.l 8(%a7),%d1 + bpl lr2 + neg.l %d1 +lr2: + bsr i_ldiv /* d1 = d0%d1 */ + move.l %d1,%d0 + tst.b 4(%a7) + bpl lr3 + neg.l %d0 +lr3: + rts + +ldivu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_ldiv + rts + +lmulu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_lmul + rts + +lremu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_ldiv + move.l %d1,%d0 + rts +* +* A in d0, B in d1, return A*B in d0 +* +i_lmul: + move.l %d3,%a2 /* save d3 */ + move.w %d1,%d2 + mulu %d0,%d2 /* d2 = Al * Bl */ + + move.l %d1,%d3 + swap %d3 + mulu %d0,%d3 /* d3 = Al * Bh */ + + swap %d0 + mulu %d1,%d0 /* d0 = Ah * Bl */ + + add.l %d3,%d0 /* d0 = (Ah*Bl + Al*Bh) */ + swap %d0 + clr.w %d0 /* d0 = (Ah*Bl + Al*Bh) << 16 */ + + add.l %d2,%d0 /* d0 = A*B */ + move.l %a2,%d3 /* restore d3 */ + rts +* +*A in d0, B in d1, return A/B in d0, A%B in d1 +* +i_ldiv: + tst.l %d1 + bne nz1 + +* divide by zero +* divu #0,%d0 /* cause trap */ + move.l #0x80000000,%d0 + move.l %d0,%d1 + rts +nz1: + move.l %d3,%a2 /* save d3 */ + cmp.l %d1,%d0 + bhi norm + beq is1 +* AB and B is not 0 +norm: + cmp.l #1,%d1 + bne not1 +* B==1, so ret A, rem 0 + clr.l %d1 + move.l %a2,%d3 /* restore d3 */ + rts +* check for A short (implies B short also) +not1: + cmp.l #0xffff,%d0 + bhi slow +* A short and B short -- use 'divu' + divu %d1,%d0 /* d0 = REM:ANS */ + swap %d0 /* d0 = ANS:REM */ + clr.l %d1 + move.w %d0,%d1 /* d1 = REM */ + clr.w %d0 + swap %d0 + move.l %a2,%d3 /* restore d3 */ + rts +* check for B short +slow: + cmp.l #0xffff,%d1 + bhi slower +* A long and B short -- use special stuff from gnu + move.l %d0,%d2 + clr.w %d2 + swap %d2 + divu %d1,%d2 /* d2 = REM:ANS of Ahi/B */ + clr.l %d3 + move.w %d2,%d3 /* d3 = Ahi/B */ + swap %d3 + + move.w %d0,%d2 /* d2 = REM << 16 + Alo */ + divu %d1,%d2 /* d2 = REM:ANS of stuff/B */ + + move.l %d2,%d1 + clr.w %d1 + swap %d1 /* d1 = REM */ + + clr.l %d0 + move.w %d2,%d0 + add.l %d3,%d0 /* d0 = ANS */ + move.l %a2,%d3 /* restore d3 */ + rts +* A>B, B > 1 +slower: + move.l #1,%d2 + clr.l %d3 +moreadj: + cmp.l %d0,%d1 + bhs adj + add.l %d2,%d2 + add.l %d1,%d1 + bpl moreadj +* we shifted B until its >A or sign bit set +* we shifted #1 (d2) along with it +adj: + cmp.l %d0,%d1 + bhi ltuns + or.l %d2,%d3 + sub.l %d1,%d0 +ltuns: + lsr.l #1,%d1 + lsr.l #1,%d2 + bne adj +* d3=answer, d0=rem + move.l %d0,%d1 + move.l %d3,%d0 + move.l %a2,%d3 /* restore d3 */ + rts + diff --git a/tests/hello_world/builtit.sh b/tests/hello_world/builtit.sh new file mode 100755 index 0000000..d33a7c7 --- /dev/null +++ b/tests/hello_world/builtit.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +CURDIR=${PWD} +cd ../.. && make clean && make install && cd ${CURDIR} && make clean && make && gens out.bin diff --git a/tests/hello_world/main.c b/tests/hello_world/main.c new file mode 100644 index 0000000..31d4b98 --- /dev/null +++ b/tests/hello_world/main.c @@ -0,0 +1,13 @@ +#include "blast.h" + +int main( ) +{ + blast_init(); + VDP_drawText("Hello World!", 1, 1); + + while(1) + { + VDP_waitVSync(); + } + return 0; +} diff --git a/tests/map_n_spr_test/Makefile b/tests/map_n_spr_test/Makefile new file mode 120000 index 0000000..6954742 --- /dev/null +++ b/tests/map_n_spr_test/Makefile @@ -0,0 +1 @@ +../../mkfiles/Makefile.sgdk1_51 \ No newline at end of file diff --git a/tests/map_n_spr_test/boot/rom_head.c b/tests/map_n_spr_test/boot/rom_head.c new file mode 100644 index 0000000..451564b --- /dev/null +++ b/tests/map_n_spr_test/boot/rom_head.c @@ -0,0 +1,43 @@ +#include "types.h" + + +const struct +{ + char console[16]; /* Console Name (16) */ + char copyright[16]; /* Copyright Information (16) */ + char title_local[48]; /* Domestic Name (48) */ + char title_int[48]; /* Overseas Name (48) */ + char serial[14]; /* Serial Number (2, 12) */ + u16 checksum; /* Checksum (2) */ + char IOSupport[16]; /* I/O Support (16) */ + u32 rom_start; /* ROM Start Address (4) */ + u32 rom_end; /* ROM End Address (4) */ + u32 ram_start; /* Start of Backup RAM (4) */ + u32 ram_end; /* End of Backup RAM (4) */ + char sram_sig[2]; /* "RA" for save ram (2) */ + u16 sram_type; /* 0xF820 for save ram on odd bytes (2) */ + u32 sram_start; /* SRAM start address - normally 0x200001 (4) */ + u32 sram_end; /* SRAM end address - start + 2*sram_size (4) */ + char modem_support[12]; /* Modem Support (24) */ + char notes[40]; /* Memo (40) */ + char region[16]; /* Country Support (16) */ +} rom_header = { + "SEGA MEGA DRIVE ", + "(C)FLEMTEAM 2013", + "SAMPLE PROGRAM ", + "SAMPLE PROGRAM ", + "GM 00000000-00", + 0x0000, + "JD ", + 0x00000000, + 0x00100000, + 0x00FF0000, + 0x00FFFFFF, + " ", + 0x0000, + 0x00200000, + 0x002001FF, + " ", + "DEMONSTRATION PROGRAM ", + "JUE " +}; diff --git a/tests/map_n_spr_test/boot/sega.s b/tests/map_n_spr_test/boot/sega.s new file mode 100644 index 0000000..9c98070 --- /dev/null +++ b/tests/map_n_spr_test/boot/sega.s @@ -0,0 +1,469 @@ +.section .text.keepboot + +*------------------------------------------------------- +* +* Sega startup code for the GNU Assembler +* Translated from: +* Sega startup code for the Sozobon C compiler +* Written by Paul W. Lee +* Modified by Charles Coty +* Modified by Stephane Dallongeville +* +*------------------------------------------------------- + + .org 0x00000000 + +_Start_Of_Rom: +_Vecteurs_68K: + dc.l 0x00FFFE00 /* Stack address */ + dc.l _Entry_Point /* Program start address */ + dc.l _Bus_Error + dc.l _Address_Error + dc.l _Illegal_Instruction + dc.l _Zero_Divide + dc.l _Chk_Instruction + dc.l _Trapv_Instruction + dc.l _Privilege_Violation + dc.l _Trace + dc.l _Line_1010_Emulation + dc.l _Line_1111_Emulation + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _INT, _EXTINT, _INT + dc.l _HINT + dc.l _INT + dc.l _VINT + dc.l _INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + + .incbin "boot/rom_head.bin", 0x10, 0x100 + +_Entry_Point: + move #0x2700,%sr + tst.l 0xa10008 + bne.s SkipJoyDetect + tst.w 0xa1000c +SkipJoyDetect: + bne.s SkipSetup + + lea Table,%a5 + movem.w (%a5)+,%d5-%d7 + movem.l (%a5)+,%a0-%a4 +* Check Version Number + move.b -0x10ff(%a1),%d0 + andi.b #0x0f,%d0 + beq.s WrongVersion +* Sega Security Code (SEGA) + move.l #0x53454741,0x2f00(%a1) +WrongVersion: + move.w (%a4),%d0 + moveq #0x00,%d0 + movea.l %d0,%a6 + move %a6,%usp + move.w %d7,(%a1) + move.w %d7,(%a2) + jmp Continue + +Table: + dc.w 0x8000,0x3fff,0x0100 + dc.l 0xA00000,0xA11100,0xA11200,0xC00000,0xC00004 + +SkipSetup: + move.w #0,%a7 + jmp _reset_entry + +Continue: + +* clear Genesis RAM + lea 0xff0000,%a0 + moveq #0,%d0 + move.w #0x3FFF,%d1 + +ClearRam: + move.l %d0,(%a0)+ + dbra %d1,ClearRam + +* copy initialized variables from ROM to Work RAM + lea _stext,%a0 + lea 0xFF0000,%a1 + move.l #_sdata,%d0 + lsr.l #1,%d0 + beq NoCopy + + subq.w #1,%d0 +CopyVar: + move.w (%a0)+,(%a1)+ + dbra %d0,CopyVar + +NoCopy: + +* Jump to initialisation process... + + move.w #0,%a7 + jmp _start_entry + + +*------------------------------------------------ +* +* interrupt functions +* +*------------------------------------------------ + +registersDump: + move.l %d0,registerState+0 + move.l %d1,registerState+4 + move.l %d2,registerState+8 + move.l %d3,registerState+12 + move.l %d4,registerState+16 + move.l %d5,registerState+20 + move.l %d6,registerState+24 + move.l %d7,registerState+28 + move.l %a0,registerState+32 + move.l %a1,registerState+36 + move.l %a2,registerState+40 + move.l %a3,registerState+44 + move.l %a4,registerState+48 + move.l %a5,registerState+52 + move.l %a6,registerState+56 + move.l %a7,registerState+60 + rts + +busAddressErrorDump: + move.w 4(%sp),ext1State + move.l 6(%sp),addrState + move.w 10(%sp),ext2State + move.w 12(%sp),srState + move.l 14(%sp),pcState + jmp registersDump + +exception4WDump: + move.w 4(%sp),srState + move.l 6(%sp),pcState + move.w 10(%sp),ext1State + jmp registersDump + +exceptionDump: + move.w 4(%sp),srState + move.l 6(%sp),pcState + jmp registersDump + + +_Bus_Error: + jsr busAddressErrorDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l busErrorCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Address_Error: + jsr busAddressErrorDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l addressErrorCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Illegal_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l illegalInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Zero_Divide: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l zeroDivideCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Chk_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l chkInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Trapv_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l trapvInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Privilege_Violation: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l privilegeViolationCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Trace: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l traceCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Line_1010_Emulation: +_Line_1111_Emulation: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l line1x1xCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Error_Exception: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l errorExceptionCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_INT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l intCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_EXTINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalExtIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_HINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalHIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_VINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalVIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +*------------------------------------------------ +* +* Copyright (c) 1988 by Sozobon, Limited. Author: Johann Ruegg +* +* Permission is granted to anyone to use this software for any purpose +* on any computer system, and to redistribute it freely, with the +* following restrictions: +* 1) No charge may be made other than reasonable charges for reproduction. +* 2) Modified versions must be clearly marked as such. +* 3) The authors are not responsible for any harmful consequences +* of using this software, even if they result from defects in it. +* +*------------------------------------------------ + +ldiv: + move.l 4(%a7),%d0 + bpl ld1 + neg.l %d0 +ld1: + move.l 8(%a7),%d1 + bpl ld2 + neg.l %d1 + eor.b #0x80,4(%a7) +ld2: + bsr i_ldiv /* d0 = d0/d1 */ + tst.b 4(%a7) + bpl ld3 + neg.l %d0 +ld3: + rts + +lmul: + move.l 4(%a7),%d0 + bpl lm1 + neg.l %d0 +lm1: + move.l 8(%a7),%d1 + bpl lm2 + neg.l %d1 + eor.b #0x80,4(%a7) +lm2: + bsr i_lmul /* d0 = d0*d1 */ + tst.b 4(%a7) + bpl lm3 + neg.l %d0 +lm3: + rts + +lrem: + move.l 4(%a7),%d0 + bpl lr1 + neg.l %d0 +lr1: + move.l 8(%a7),%d1 + bpl lr2 + neg.l %d1 +lr2: + bsr i_ldiv /* d1 = d0%d1 */ + move.l %d1,%d0 + tst.b 4(%a7) + bpl lr3 + neg.l %d0 +lr3: + rts + +ldivu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_ldiv + rts + +lmulu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_lmul + rts + +lremu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_ldiv + move.l %d1,%d0 + rts +* +* A in d0, B in d1, return A*B in d0 +* +i_lmul: + move.l %d3,%a2 /* save d3 */ + move.w %d1,%d2 + mulu %d0,%d2 /* d2 = Al * Bl */ + + move.l %d1,%d3 + swap %d3 + mulu %d0,%d3 /* d3 = Al * Bh */ + + swap %d0 + mulu %d1,%d0 /* d0 = Ah * Bl */ + + add.l %d3,%d0 /* d0 = (Ah*Bl + Al*Bh) */ + swap %d0 + clr.w %d0 /* d0 = (Ah*Bl + Al*Bh) << 16 */ + + add.l %d2,%d0 /* d0 = A*B */ + move.l %a2,%d3 /* restore d3 */ + rts +* +*A in d0, B in d1, return A/B in d0, A%B in d1 +* +i_ldiv: + tst.l %d1 + bne nz1 + +* divide by zero +* divu #0,%d0 /* cause trap */ + move.l #0x80000000,%d0 + move.l %d0,%d1 + rts +nz1: + move.l %d3,%a2 /* save d3 */ + cmp.l %d1,%d0 + bhi norm + beq is1 +* AB and B is not 0 +norm: + cmp.l #1,%d1 + bne not1 +* B==1, so ret A, rem 0 + clr.l %d1 + move.l %a2,%d3 /* restore d3 */ + rts +* check for A short (implies B short also) +not1: + cmp.l #0xffff,%d0 + bhi slow +* A short and B short -- use 'divu' + divu %d1,%d0 /* d0 = REM:ANS */ + swap %d0 /* d0 = ANS:REM */ + clr.l %d1 + move.w %d0,%d1 /* d1 = REM */ + clr.w %d0 + swap %d0 + move.l %a2,%d3 /* restore d3 */ + rts +* check for B short +slow: + cmp.l #0xffff,%d1 + bhi slower +* A long and B short -- use special stuff from gnu + move.l %d0,%d2 + clr.w %d2 + swap %d2 + divu %d1,%d2 /* d2 = REM:ANS of Ahi/B */ + clr.l %d3 + move.w %d2,%d3 /* d3 = Ahi/B */ + swap %d3 + + move.w %d0,%d2 /* d2 = REM << 16 + Alo */ + divu %d1,%d2 /* d2 = REM:ANS of stuff/B */ + + move.l %d2,%d1 + clr.w %d1 + swap %d1 /* d1 = REM */ + + clr.l %d0 + move.w %d2,%d0 + add.l %d3,%d0 /* d0 = ANS */ + move.l %a2,%d3 /* restore d3 */ + rts +* A>B, B > 1 +slower: + move.l #1,%d2 + clr.l %d3 +moreadj: + cmp.l %d0,%d1 + bhs adj + add.l %d2,%d2 + add.l %d1,%d1 + bpl moreadj +* we shifted B until its >A or sign bit set +* we shifted #1 (d2) along with it +adj: + cmp.l %d0,%d1 + bhi ltuns + or.l %d2,%d3 + sub.l %d1,%d0 +ltuns: + lsr.l #1,%d1 + lsr.l #1,%d2 + bne adj +* d3=answer, d0=rem + move.l %d0,%d1 + move.l %d3,%d0 + move.l %a2,%d3 /* restore d3 */ + rts + diff --git a/tests/map_n_spr_test/builtit.sh b/tests/map_n_spr_test/builtit.sh new file mode 100755 index 0000000..d33a7c7 --- /dev/null +++ b/tests/map_n_spr_test/builtit.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +CURDIR=${PWD} +cd ../.. && make clean && make install && cd ${CURDIR} && make clean && make && gens out.bin diff --git a/tests/map_n_spr_test/main.c b/tests/map_n_spr_test/main.c new file mode 100644 index 0000000..6ac2f19 --- /dev/null +++ b/tests/map_n_spr_test/main.c @@ -0,0 +1,154 @@ +#include "blast.h" +#include "images.h" +#include "terrain_map1.h" + +u16 terrain_tile_offset; +blastmap terrain1map; + +char str[10]; + +#define SPR_NBTILES 4 //tiles needed for our sprite + +//const is used to keep tile in ROM, not in RAM +const u32 spriteTiles[SPR_NBTILES*8]= +{ + 0x00001111, //Tile Top Left + 0x00001111, + 0x00111144, + 0x00111144, + 0x11112244, + 0x11112244, + 0x11112244, + 0x11112244, + + 0x11112222, //Tile Bottom Left + 0x11112222, + 0x11112222, + 0x11112222, + 0x00111122, + 0x00111122, + 0x00001111, + 0x00001111, + + 0x11110000, //Tile Top Right + 0x11110000, + 0x44111100, + 0x44111100, + 0x44221111, + 0x44221111, + 0x44221111, + 0x44221111, + + 0x22221111, //Tile Bottom Right + 0x22221111, + 0x22221111, + 0x22221111, + 0x22111100, + 0x22111100, + 0x11110000, + 0x11110000 +}; + +#define DEBUG 1 +int main( ) +{ + spritedef mySprite; + u16 sprite_idx = 0; + + //u8* colls; + u16 sprite_bmp_offset = 1; + u16 movestate = 0; + + blast_init(); + + //ind = TILE_USERINDEX+sprite_bmp_offset; + + uintToStr(terrain1.tileset->compression, str, 3); + VDP_drawText(str, 5, 5); + + u16 ind = TILE_USERINDEX; + //VDP_drawImageEx(PLAN_B, &terrain1, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE); + + /* + VDP_loadTileData(terrain1.tileset->tiles, + TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, ind), + terrain1.tileset->numTile, 0); + //VDP_setMap(PLAN_B, terrain1.map, ind, 0, 0); + VDP_loadTileSet((TileSet*)terrain1.tileset, ind & TILE_INDEX_MASK, TRUE); + blastmap_init(&terrain1map, &terrain1_map, (u16*)terrain1.map->tilemap, ind, PLAN_B); + load_visible_map(&terrain1map,0,0); + + + + */ + VDP_setPalette(PAL0, (u16*)terrain1.palette->data); + //ind += terrain1.tileset->numTile; + //terrain_tile_offset = ind; + + //VDP_drawText(str, 5, 5); + + //VDP_loadTileSet(&(terrain1.tileset), ind, COMPRESSION_NONE); + //ind += terrain1.tileset->numTile; + //terrain_tile_offset = ind; + + /* + terrain_tile_offset = load_bmp( + (u32*) terrain1.tileset->tiles, + terrain1.map->w, + terrain1.map->h + ); + */ +#ifdef DEBUG + terrain_tile_offset = load_img(&terrain1); + VDP_setPalette(PAL0, (u16*)terrain1.palette->data); + + blastmap_init(&terrain1map, &terrain1_map, (u16*)terrain1.tilemap->tilemap, terrain_tile_offset, BG_A); + load_visible_map(&terrain1map,0,0); + + uintToStr(terrain1.tileset->numTile,str,3); + + sprite_bmp_offset = load_tile( + (u32*) spriteTiles, + 32, + 8 + ); + + sprite_idx = sprite_init( + &mySprite, + sprite_bmp_offset, + 1, + 0, + 64, + 2, + 2, + PAL0 + ); +#endif + + while(1) + { + VDP_drawText("map and sprite test", 2, 2); + switch(movestate) { + case 0: + mySprite.posy++; + //mySprite.posx++; + if(mySprite.posy > 180){ + movestate=1; + } + break; + case 1: + mySprite.posy--; + //mySprite.posx--; + if(mySprite.posy < 5){ + movestate=0; + } + break; + } + if((mySprite.posy % 2) == 0) { + mySprite.posx++; + } + VDP_waitVSync(); + + } + return 0; +} diff --git a/tests/map_n_spr_test/res/images.res b/tests/map_n_spr_test/res/images.res new file mode 100644 index 0000000..c34b8c0 --- /dev/null +++ b/tests/map_n_spr_test/res/images.res @@ -0,0 +1 @@ +IMAGE terrain1 "terrain1.bmp" 0 diff --git a/tests/map_n_spr_test/res/terrain1.bmp b/tests/map_n_spr_test/res/terrain1.bmp new file mode 100644 index 0000000..fb825f2 Binary files /dev/null and b/tests/map_n_spr_test/res/terrain1.bmp differ diff --git a/tests/map_n_spr_test/res/terrain1.tmx b/tests/map_n_spr_test/res/terrain1.tmx new file mode 100644 index 0000000..8fd204e --- /dev/null +++ b/tests/map_n_spr_test/res/terrain1.tmx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, +2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,4,1,7,1,1,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,1,2,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, +2,2,2,2,2,2,2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9, +2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,9,9,9, +2,2,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,9,9,9, +2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,9,9,9, +2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,9,9, +2,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +2,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,3,3,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,3,3,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,10,10,10,10,10,10,10,10,10,3,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,3,3,3,3,3,3,2,2,10,10,10,10,10,10,10,10,10,10,10,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,3,3,3,3,3,2,10,10,10,10,10,10,10,10,10,10,3,3,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,3,3,3,3,3,3,10,10,10,3,3,3,3,3,3,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +3,3,3,3,2,2,2,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,10,10,10,10,10,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,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2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,9,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,2,2,2,2,2,2,2, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,9,9,9,9,2,2,2,2,2,2,2,2,2,2,2,9,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,9,2,2,2,2,2,2, +2,2,2,2,2,2,2,2,2,2,2,9,9,9,9,9,9,9,9,9,2,2,2,2,2,9,9,9,9,9,9,9,2,2,2,2,2,2,2,2,9,9,9,9,2,2,2,2,2,2,2,2,2,9,9,9,9,9,9,9,2,2,9,9, +9,9,2,2,2,2,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9 + + + diff --git a/tests/map_test/Makefile b/tests/map_test/Makefile new file mode 120000 index 0000000..6954742 --- /dev/null +++ b/tests/map_test/Makefile @@ -0,0 +1 @@ +../../mkfiles/Makefile.sgdk1_51 \ No newline at end of file diff --git a/tests/map_test/boot/rom_head.c b/tests/map_test/boot/rom_head.c new file mode 100644 index 0000000..451564b --- /dev/null +++ b/tests/map_test/boot/rom_head.c @@ -0,0 +1,43 @@ +#include "types.h" + + +const struct +{ + char console[16]; /* Console Name (16) */ + char copyright[16]; /* Copyright Information (16) */ + char title_local[48]; /* Domestic Name (48) */ + char title_int[48]; /* Overseas Name (48) */ + char serial[14]; /* Serial Number (2, 12) */ + u16 checksum; /* Checksum (2) */ + char IOSupport[16]; /* I/O Support (16) */ + u32 rom_start; /* ROM Start Address (4) */ + u32 rom_end; /* ROM End Address (4) */ + u32 ram_start; /* Start of Backup RAM (4) */ + u32 ram_end; /* End of Backup RAM (4) */ + char sram_sig[2]; /* "RA" for save ram (2) */ + u16 sram_type; /* 0xF820 for save ram on odd bytes (2) */ + u32 sram_start; /* SRAM start address - normally 0x200001 (4) */ + u32 sram_end; /* SRAM end address - start + 2*sram_size (4) */ + char modem_support[12]; /* Modem Support (24) */ + char notes[40]; /* Memo (40) */ + char region[16]; /* Country Support (16) */ +} rom_header = { + "SEGA MEGA DRIVE ", + "(C)FLEMTEAM 2013", + "SAMPLE PROGRAM ", + "SAMPLE PROGRAM ", + "GM 00000000-00", + 0x0000, + "JD ", + 0x00000000, + 0x00100000, + 0x00FF0000, + 0x00FFFFFF, + " ", + 0x0000, + 0x00200000, + 0x002001FF, + " ", + "DEMONSTRATION PROGRAM ", + "JUE " +}; diff --git a/tests/map_test/boot/sega.s b/tests/map_test/boot/sega.s new file mode 100644 index 0000000..9c98070 --- /dev/null +++ b/tests/map_test/boot/sega.s @@ -0,0 +1,469 @@ +.section .text.keepboot + +*------------------------------------------------------- +* +* Sega startup code for the GNU Assembler +* Translated from: +* Sega startup code for the Sozobon C compiler +* Written by Paul W. Lee +* Modified by Charles Coty +* Modified by Stephane Dallongeville +* +*------------------------------------------------------- + + .org 0x00000000 + +_Start_Of_Rom: +_Vecteurs_68K: + dc.l 0x00FFFE00 /* Stack address */ + dc.l _Entry_Point /* Program start address */ + dc.l _Bus_Error + dc.l _Address_Error + dc.l _Illegal_Instruction + dc.l _Zero_Divide + dc.l _Chk_Instruction + dc.l _Trapv_Instruction + dc.l _Privilege_Violation + dc.l _Trace + dc.l _Line_1010_Emulation + dc.l _Line_1111_Emulation + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _INT, _EXTINT, _INT + dc.l _HINT + dc.l _INT + dc.l _VINT + dc.l _INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + + .incbin "boot/rom_head.bin", 0x10, 0x100 + +_Entry_Point: + move #0x2700,%sr + tst.l 0xa10008 + bne.s SkipJoyDetect + tst.w 0xa1000c +SkipJoyDetect: + bne.s SkipSetup + + lea Table,%a5 + movem.w (%a5)+,%d5-%d7 + movem.l (%a5)+,%a0-%a4 +* Check Version Number + move.b -0x10ff(%a1),%d0 + andi.b #0x0f,%d0 + beq.s WrongVersion +* Sega Security Code (SEGA) + move.l #0x53454741,0x2f00(%a1) +WrongVersion: + move.w (%a4),%d0 + moveq #0x00,%d0 + movea.l %d0,%a6 + move %a6,%usp + move.w %d7,(%a1) + move.w %d7,(%a2) + jmp Continue + +Table: + dc.w 0x8000,0x3fff,0x0100 + dc.l 0xA00000,0xA11100,0xA11200,0xC00000,0xC00004 + +SkipSetup: + move.w #0,%a7 + jmp _reset_entry + +Continue: + +* clear Genesis RAM + lea 0xff0000,%a0 + moveq #0,%d0 + move.w #0x3FFF,%d1 + +ClearRam: + move.l %d0,(%a0)+ + dbra %d1,ClearRam + +* copy initialized variables from ROM to Work RAM + lea _stext,%a0 + lea 0xFF0000,%a1 + move.l #_sdata,%d0 + lsr.l #1,%d0 + beq NoCopy + + subq.w #1,%d0 +CopyVar: + move.w (%a0)+,(%a1)+ + dbra %d0,CopyVar + +NoCopy: + +* Jump to initialisation process... + + move.w #0,%a7 + jmp _start_entry + + +*------------------------------------------------ +* +* interrupt functions +* +*------------------------------------------------ + +registersDump: + move.l %d0,registerState+0 + move.l %d1,registerState+4 + move.l %d2,registerState+8 + move.l %d3,registerState+12 + move.l %d4,registerState+16 + move.l %d5,registerState+20 + move.l %d6,registerState+24 + move.l %d7,registerState+28 + move.l %a0,registerState+32 + move.l %a1,registerState+36 + move.l %a2,registerState+40 + move.l %a3,registerState+44 + move.l %a4,registerState+48 + move.l %a5,registerState+52 + move.l %a6,registerState+56 + move.l %a7,registerState+60 + rts + +busAddressErrorDump: + move.w 4(%sp),ext1State + move.l 6(%sp),addrState + move.w 10(%sp),ext2State + move.w 12(%sp),srState + move.l 14(%sp),pcState + jmp registersDump + +exception4WDump: + move.w 4(%sp),srState + move.l 6(%sp),pcState + move.w 10(%sp),ext1State + jmp registersDump + +exceptionDump: + move.w 4(%sp),srState + move.l 6(%sp),pcState + jmp registersDump + + +_Bus_Error: + jsr busAddressErrorDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l busErrorCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Address_Error: + jsr busAddressErrorDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l addressErrorCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Illegal_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l illegalInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Zero_Divide: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l zeroDivideCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Chk_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l chkInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Trapv_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l trapvInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Privilege_Violation: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l privilegeViolationCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Trace: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l traceCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Line_1010_Emulation: +_Line_1111_Emulation: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l line1x1xCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Error_Exception: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l errorExceptionCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_INT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l intCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_EXTINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalExtIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_HINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalHIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_VINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalVIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +*------------------------------------------------ +* +* Copyright (c) 1988 by Sozobon, Limited. Author: Johann Ruegg +* +* Permission is granted to anyone to use this software for any purpose +* on any computer system, and to redistribute it freely, with the +* following restrictions: +* 1) No charge may be made other than reasonable charges for reproduction. +* 2) Modified versions must be clearly marked as such. +* 3) The authors are not responsible for any harmful consequences +* of using this software, even if they result from defects in it. +* +*------------------------------------------------ + +ldiv: + move.l 4(%a7),%d0 + bpl ld1 + neg.l %d0 +ld1: + move.l 8(%a7),%d1 + bpl ld2 + neg.l %d1 + eor.b #0x80,4(%a7) +ld2: + bsr i_ldiv /* d0 = d0/d1 */ + tst.b 4(%a7) + bpl ld3 + neg.l %d0 +ld3: + rts + +lmul: + move.l 4(%a7),%d0 + bpl lm1 + neg.l %d0 +lm1: + move.l 8(%a7),%d1 + bpl lm2 + neg.l %d1 + eor.b #0x80,4(%a7) +lm2: + bsr i_lmul /* d0 = d0*d1 */ + tst.b 4(%a7) + bpl lm3 + neg.l %d0 +lm3: + rts + +lrem: + move.l 4(%a7),%d0 + bpl lr1 + neg.l %d0 +lr1: + move.l 8(%a7),%d1 + bpl lr2 + neg.l %d1 +lr2: + bsr i_ldiv /* d1 = d0%d1 */ + move.l %d1,%d0 + tst.b 4(%a7) + bpl lr3 + neg.l %d0 +lr3: + rts + +ldivu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_ldiv + rts + +lmulu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_lmul + rts + +lremu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_ldiv + move.l %d1,%d0 + rts +* +* A in d0, B in d1, return A*B in d0 +* +i_lmul: + move.l %d3,%a2 /* save d3 */ + move.w %d1,%d2 + mulu %d0,%d2 /* d2 = Al * Bl */ + + move.l %d1,%d3 + swap %d3 + mulu %d0,%d3 /* d3 = Al * Bh */ + + swap %d0 + mulu %d1,%d0 /* d0 = Ah * Bl */ + + add.l %d3,%d0 /* d0 = (Ah*Bl + Al*Bh) */ + swap %d0 + clr.w %d0 /* d0 = (Ah*Bl + Al*Bh) << 16 */ + + add.l %d2,%d0 /* d0 = A*B */ + move.l %a2,%d3 /* restore d3 */ + rts +* +*A in d0, B in d1, return A/B in d0, A%B in d1 +* +i_ldiv: + tst.l %d1 + bne nz1 + +* divide by zero +* divu #0,%d0 /* cause trap */ + move.l #0x80000000,%d0 + move.l %d0,%d1 + rts +nz1: + move.l %d3,%a2 /* save d3 */ + cmp.l %d1,%d0 + bhi norm + beq is1 +* AB and B is not 0 +norm: + cmp.l #1,%d1 + bne not1 +* B==1, so ret A, rem 0 + clr.l %d1 + move.l %a2,%d3 /* restore d3 */ + rts +* check for A short (implies B short also) +not1: + cmp.l #0xffff,%d0 + bhi slow +* A short and B short -- use 'divu' + divu %d1,%d0 /* d0 = REM:ANS */ + swap %d0 /* d0 = ANS:REM */ + clr.l %d1 + move.w %d0,%d1 /* d1 = REM */ + clr.w %d0 + swap %d0 + move.l %a2,%d3 /* restore d3 */ + rts +* check for B short +slow: + cmp.l #0xffff,%d1 + bhi slower +* A long and B short -- use special stuff from gnu + move.l %d0,%d2 + clr.w %d2 + swap %d2 + divu %d1,%d2 /* d2 = REM:ANS of Ahi/B */ + clr.l %d3 + move.w %d2,%d3 /* d3 = Ahi/B */ + swap %d3 + + move.w %d0,%d2 /* d2 = REM << 16 + Alo */ + divu %d1,%d2 /* d2 = REM:ANS of stuff/B */ + + move.l %d2,%d1 + clr.w %d1 + swap %d1 /* d1 = REM */ + + clr.l %d0 + move.w %d2,%d0 + add.l %d3,%d0 /* d0 = ANS */ + move.l %a2,%d3 /* restore d3 */ + rts +* A>B, B > 1 +slower: + move.l #1,%d2 + clr.l %d3 +moreadj: + cmp.l %d0,%d1 + bhs adj + add.l %d2,%d2 + add.l %d1,%d1 + bpl moreadj +* we shifted B until its >A or sign bit set +* we shifted #1 (d2) along with it +adj: + cmp.l %d0,%d1 + bhi ltuns + or.l %d2,%d3 + sub.l %d1,%d0 +ltuns: + lsr.l #1,%d1 + lsr.l #1,%d2 + bne adj +* d3=answer, d0=rem + move.l %d0,%d1 + move.l %d3,%d0 + move.l %a2,%d3 /* restore d3 */ + rts + diff --git a/tests/map_test/builtit.sh b/tests/map_test/builtit.sh new file mode 100755 index 0000000..d33a7c7 --- /dev/null +++ b/tests/map_test/builtit.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +CURDIR=${PWD} +cd ../.. && make clean && make install && cd ${CURDIR} && make clean && make && gens out.bin diff --git a/tests/map_test/main.c b/tests/map_test/main.c new file mode 100644 index 0000000..47063a7 --- /dev/null +++ b/tests/map_test/main.c @@ -0,0 +1,65 @@ +#include "blast.h" +#include "images.h" +#include "terrain_map1.h" + +u16 terrain_tile_offset; +blastmap terrain1map; + +char str[10]; + +#define DEBUG 1 +int main( ) +{ + blast_init(); + //ind = TILE_USERINDEX+sprite_bmp_offset; + + uintToStr(terrain1.tileset->compression, str, 3); + VDP_drawText(str, 5, 5); + + u16 ind = TILE_USERINDEX; + //VDP_drawImageEx(PLAN_B, &terrain1, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE); + + /* + VDP_loadTileData(terrain1.tileset->tiles, + TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, ind), + terrain1.tileset->numTile, 0); + //VDP_setMap(PLAN_B, terrain1.map, ind, 0, 0); + VDP_loadTileSet((TileSet*)terrain1.tileset, ind & TILE_INDEX_MASK, TRUE); + blastmap_init(&terrain1map, &terrain1_map, (u16*)terrain1.map->tilemap, ind, PLAN_B); + load_visible_map(&terrain1map,0,0); + + + + */ + VDP_setPalette(PAL0, (u16*)terrain1.palette->data); + //ind += terrain1.tileset->numTile; + //terrain_tile_offset = ind; + + //VDP_drawText(str, 5, 5); + + //VDP_loadTileSet(&(terrain1.tileset), ind, COMPRESSION_NONE); + //ind += terrain1.tileset->numTile; + //terrain_tile_offset = ind; + + /* + terrain_tile_offset = load_bmp( + (u32*) terrain1.tileset->tiles, + terrain1.map->w, + terrain1.map->h + ); + */ + terrain_tile_offset = load_img(&terrain1); + VDP_setPalette(PAL0, (u16*)terrain1.palette->data); + + blastmap_init(&terrain1map, &terrain1_map, (u16*)terrain1.tilemap->tilemap, terrain_tile_offset, BG_A); + load_visible_map(&terrain1map,0,0); + + uintToStr(terrain1.tileset->numTile,str,3); + + while(1) + { + VDP_drawText("map test", 2, 2); + VDP_waitVSync(); + } + return 0; +} diff --git a/tests/map_test/res/images.res b/tests/map_test/res/images.res new file mode 100644 index 0000000..c34b8c0 --- /dev/null +++ b/tests/map_test/res/images.res @@ -0,0 +1 @@ +IMAGE terrain1 "terrain1.bmp" 0 diff --git a/tests/map_test/res/terrain1.bmp b/tests/map_test/res/terrain1.bmp new file mode 100644 index 0000000..fb825f2 Binary files /dev/null and b/tests/map_test/res/terrain1.bmp differ diff --git a/tests/map_test/res/terrain1.tmx b/tests/map_test/res/terrain1.tmx new file mode 100644 index 0000000..8fd204e --- /dev/null +++ b/tests/map_test/res/terrain1.tmx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, +2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,4,1,7,1,1,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,1,2,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, +2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,6,2,2,2,2,2,2,5,2,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,2, +2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,1,2,2,2,2,2,6,2,2,2,2,2,2,5,2,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,2,2, +2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2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,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,9,9,9, +2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,9,9, +2,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +2,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,3,3,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,3,3,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,10,10,10,10,10,10,10,10,10,3,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,3,3,3,3,3,3,2,2,10,10,10,10,10,10,10,10,10,10,10,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,3,3,3,3,3,2,10,10,10,10,10,10,10,10,10,10,3,3,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9, +3,3,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,3,3,3,3,3,3,10,10,10,3,3,3,3,3,3,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +3,3,3,3,2,2,2,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,10,10,10,10,10,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9, +3,3,3,2,2,2,2,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,2,3,3,3,3,3,10,10,10,10,10,10,10,10,10,10,3,3,3,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,2,2,2,2, +3,3,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,10,10,10,10,10,3,10,10,10,10,10,10,10,10,10,10,10,10,10,10,2,2,2,2,2,2,2, +2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2,2,2,9,2,2,2,2,2,2,2, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,9,9,9,9,2,2,2,2,2,2,2,2,2,2,2,9,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,9,2,2,2,2,2,2, +2,2,2,2,2,2,2,2,2,2,2,9,9,9,9,9,9,9,9,9,2,2,2,2,2,9,9,9,9,9,9,9,2,2,2,2,2,2,2,2,9,9,9,9,2,2,2,2,2,2,2,2,2,9,9,9,9,9,9,9,2,2,9,9, +9,9,2,2,2,2,2,2,2,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9 + + + diff --git a/tests/sprite_test/Makefile b/tests/sprite_test/Makefile new file mode 120000 index 0000000..6954742 --- /dev/null +++ b/tests/sprite_test/Makefile @@ -0,0 +1 @@ +../../mkfiles/Makefile.sgdk1_51 \ No newline at end of file diff --git a/tests/sprite_test/boot/rom_head.c b/tests/sprite_test/boot/rom_head.c new file mode 100644 index 0000000..451564b --- /dev/null +++ b/tests/sprite_test/boot/rom_head.c @@ -0,0 +1,43 @@ +#include "types.h" + + +const struct +{ + char console[16]; /* Console Name (16) */ + char copyright[16]; /* Copyright Information (16) */ + char title_local[48]; /* Domestic Name (48) */ + char title_int[48]; /* Overseas Name (48) */ + char serial[14]; /* Serial Number (2, 12) */ + u16 checksum; /* Checksum (2) */ + char IOSupport[16]; /* I/O Support (16) */ + u32 rom_start; /* ROM Start Address (4) */ + u32 rom_end; /* ROM End Address (4) */ + u32 ram_start; /* Start of Backup RAM (4) */ + u32 ram_end; /* End of Backup RAM (4) */ + char sram_sig[2]; /* "RA" for save ram (2) */ + u16 sram_type; /* 0xF820 for save ram on odd bytes (2) */ + u32 sram_start; /* SRAM start address - normally 0x200001 (4) */ + u32 sram_end; /* SRAM end address - start + 2*sram_size (4) */ + char modem_support[12]; /* Modem Support (24) */ + char notes[40]; /* Memo (40) */ + char region[16]; /* Country Support (16) */ +} rom_header = { + "SEGA MEGA DRIVE ", + "(C)FLEMTEAM 2013", + "SAMPLE PROGRAM ", + "SAMPLE PROGRAM ", + "GM 00000000-00", + 0x0000, + "JD ", + 0x00000000, + 0x00100000, + 0x00FF0000, + 0x00FFFFFF, + " ", + 0x0000, + 0x00200000, + 0x002001FF, + " ", + "DEMONSTRATION PROGRAM ", + "JUE " +}; diff --git a/tests/sprite_test/boot/sega.s b/tests/sprite_test/boot/sega.s new file mode 100644 index 0000000..9c98070 --- /dev/null +++ b/tests/sprite_test/boot/sega.s @@ -0,0 +1,469 @@ +.section .text.keepboot + +*------------------------------------------------------- +* +* Sega startup code for the GNU Assembler +* Translated from: +* Sega startup code for the Sozobon C compiler +* Written by Paul W. Lee +* Modified by Charles Coty +* Modified by Stephane Dallongeville +* +*------------------------------------------------------- + + .org 0x00000000 + +_Start_Of_Rom: +_Vecteurs_68K: + dc.l 0x00FFFE00 /* Stack address */ + dc.l _Entry_Point /* Program start address */ + dc.l _Bus_Error + dc.l _Address_Error + dc.l _Illegal_Instruction + dc.l _Zero_Divide + dc.l _Chk_Instruction + dc.l _Trapv_Instruction + dc.l _Privilege_Violation + dc.l _Trace + dc.l _Line_1010_Emulation + dc.l _Line_1111_Emulation + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _Error_Exception, _Error_Exception, _Error_Exception + dc.l _Error_Exception, _INT, _EXTINT, _INT + dc.l _HINT + dc.l _INT + dc.l _VINT + dc.l _INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT + + .incbin "boot/rom_head.bin", 0x10, 0x100 + +_Entry_Point: + move #0x2700,%sr + tst.l 0xa10008 + bne.s SkipJoyDetect + tst.w 0xa1000c +SkipJoyDetect: + bne.s SkipSetup + + lea Table,%a5 + movem.w (%a5)+,%d5-%d7 + movem.l (%a5)+,%a0-%a4 +* Check Version Number + move.b -0x10ff(%a1),%d0 + andi.b #0x0f,%d0 + beq.s WrongVersion +* Sega Security Code (SEGA) + move.l #0x53454741,0x2f00(%a1) +WrongVersion: + move.w (%a4),%d0 + moveq #0x00,%d0 + movea.l %d0,%a6 + move %a6,%usp + move.w %d7,(%a1) + move.w %d7,(%a2) + jmp Continue + +Table: + dc.w 0x8000,0x3fff,0x0100 + dc.l 0xA00000,0xA11100,0xA11200,0xC00000,0xC00004 + +SkipSetup: + move.w #0,%a7 + jmp _reset_entry + +Continue: + +* clear Genesis RAM + lea 0xff0000,%a0 + moveq #0,%d0 + move.w #0x3FFF,%d1 + +ClearRam: + move.l %d0,(%a0)+ + dbra %d1,ClearRam + +* copy initialized variables from ROM to Work RAM + lea _stext,%a0 + lea 0xFF0000,%a1 + move.l #_sdata,%d0 + lsr.l #1,%d0 + beq NoCopy + + subq.w #1,%d0 +CopyVar: + move.w (%a0)+,(%a1)+ + dbra %d0,CopyVar + +NoCopy: + +* Jump to initialisation process... + + move.w #0,%a7 + jmp _start_entry + + +*------------------------------------------------ +* +* interrupt functions +* +*------------------------------------------------ + +registersDump: + move.l %d0,registerState+0 + move.l %d1,registerState+4 + move.l %d2,registerState+8 + move.l %d3,registerState+12 + move.l %d4,registerState+16 + move.l %d5,registerState+20 + move.l %d6,registerState+24 + move.l %d7,registerState+28 + move.l %a0,registerState+32 + move.l %a1,registerState+36 + move.l %a2,registerState+40 + move.l %a3,registerState+44 + move.l %a4,registerState+48 + move.l %a5,registerState+52 + move.l %a6,registerState+56 + move.l %a7,registerState+60 + rts + +busAddressErrorDump: + move.w 4(%sp),ext1State + move.l 6(%sp),addrState + move.w 10(%sp),ext2State + move.w 12(%sp),srState + move.l 14(%sp),pcState + jmp registersDump + +exception4WDump: + move.w 4(%sp),srState + move.l 6(%sp),pcState + move.w 10(%sp),ext1State + jmp registersDump + +exceptionDump: + move.w 4(%sp),srState + move.l 6(%sp),pcState + jmp registersDump + + +_Bus_Error: + jsr busAddressErrorDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l busErrorCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Address_Error: + jsr busAddressErrorDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l addressErrorCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Illegal_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l illegalInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Zero_Divide: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l zeroDivideCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Chk_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l chkInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Trapv_Instruction: + jsr exception4WDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l trapvInstCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Privilege_Violation: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l privilegeViolationCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Trace: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l traceCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Line_1010_Emulation: +_Line_1111_Emulation: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l line1x1xCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_Error_Exception: + jsr exceptionDump + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l errorExceptionCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_INT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l intCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_EXTINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalExtIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_HINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalHIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +_VINT: + movem.l %d0-%d1/%a0-%a1,-(%sp) + move.l internalVIntCB, %a0 + jsr (%a0) + movem.l (%sp)+,%d0-%d1/%a0-%a1 + rte + +*------------------------------------------------ +* +* Copyright (c) 1988 by Sozobon, Limited. Author: Johann Ruegg +* +* Permission is granted to anyone to use this software for any purpose +* on any computer system, and to redistribute it freely, with the +* following restrictions: +* 1) No charge may be made other than reasonable charges for reproduction. +* 2) Modified versions must be clearly marked as such. +* 3) The authors are not responsible for any harmful consequences +* of using this software, even if they result from defects in it. +* +*------------------------------------------------ + +ldiv: + move.l 4(%a7),%d0 + bpl ld1 + neg.l %d0 +ld1: + move.l 8(%a7),%d1 + bpl ld2 + neg.l %d1 + eor.b #0x80,4(%a7) +ld2: + bsr i_ldiv /* d0 = d0/d1 */ + tst.b 4(%a7) + bpl ld3 + neg.l %d0 +ld3: + rts + +lmul: + move.l 4(%a7),%d0 + bpl lm1 + neg.l %d0 +lm1: + move.l 8(%a7),%d1 + bpl lm2 + neg.l %d1 + eor.b #0x80,4(%a7) +lm2: + bsr i_lmul /* d0 = d0*d1 */ + tst.b 4(%a7) + bpl lm3 + neg.l %d0 +lm3: + rts + +lrem: + move.l 4(%a7),%d0 + bpl lr1 + neg.l %d0 +lr1: + move.l 8(%a7),%d1 + bpl lr2 + neg.l %d1 +lr2: + bsr i_ldiv /* d1 = d0%d1 */ + move.l %d1,%d0 + tst.b 4(%a7) + bpl lr3 + neg.l %d0 +lr3: + rts + +ldivu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_ldiv + rts + +lmulu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_lmul + rts + +lremu: + move.l 4(%a7),%d0 + move.l 8(%a7),%d1 + bsr i_ldiv + move.l %d1,%d0 + rts +* +* A in d0, B in d1, return A*B in d0 +* +i_lmul: + move.l %d3,%a2 /* save d3 */ + move.w %d1,%d2 + mulu %d0,%d2 /* d2 = Al * Bl */ + + move.l %d1,%d3 + swap %d3 + mulu %d0,%d3 /* d3 = Al * Bh */ + + swap %d0 + mulu %d1,%d0 /* d0 = Ah * Bl */ + + add.l %d3,%d0 /* d0 = (Ah*Bl + Al*Bh) */ + swap %d0 + clr.w %d0 /* d0 = (Ah*Bl + Al*Bh) << 16 */ + + add.l %d2,%d0 /* d0 = A*B */ + move.l %a2,%d3 /* restore d3 */ + rts +* +*A in d0, B in d1, return A/B in d0, A%B in d1 +* +i_ldiv: + tst.l %d1 + bne nz1 + +* divide by zero +* divu #0,%d0 /* cause trap */ + move.l #0x80000000,%d0 + move.l %d0,%d1 + rts +nz1: + move.l %d3,%a2 /* save d3 */ + cmp.l %d1,%d0 + bhi norm + beq is1 +* AB and B is not 0 +norm: + cmp.l #1,%d1 + bne not1 +* B==1, so ret A, rem 0 + clr.l %d1 + move.l %a2,%d3 /* restore d3 */ + rts +* check for A short (implies B short also) +not1: + cmp.l #0xffff,%d0 + bhi slow +* A short and B short -- use 'divu' + divu %d1,%d0 /* d0 = REM:ANS */ + swap %d0 /* d0 = ANS:REM */ + clr.l %d1 + move.w %d0,%d1 /* d1 = REM */ + clr.w %d0 + swap %d0 + move.l %a2,%d3 /* restore d3 */ + rts +* check for B short +slow: + cmp.l #0xffff,%d1 + bhi slower +* A long and B short -- use special stuff from gnu + move.l %d0,%d2 + clr.w %d2 + swap %d2 + divu %d1,%d2 /* d2 = REM:ANS of Ahi/B */ + clr.l %d3 + move.w %d2,%d3 /* d3 = Ahi/B */ + swap %d3 + + move.w %d0,%d2 /* d2 = REM << 16 + Alo */ + divu %d1,%d2 /* d2 = REM:ANS of stuff/B */ + + move.l %d2,%d1 + clr.w %d1 + swap %d1 /* d1 = REM */ + + clr.l %d0 + move.w %d2,%d0 + add.l %d3,%d0 /* d0 = ANS */ + move.l %a2,%d3 /* restore d3 */ + rts +* A>B, B > 1 +slower: + move.l #1,%d2 + clr.l %d3 +moreadj: + cmp.l %d0,%d1 + bhs adj + add.l %d2,%d2 + add.l %d1,%d1 + bpl moreadj +* we shifted B until its >A or sign bit set +* we shifted #1 (d2) along with it +adj: + cmp.l %d0,%d1 + bhi ltuns + or.l %d2,%d3 + sub.l %d1,%d0 +ltuns: + lsr.l #1,%d1 + lsr.l #1,%d2 + bne adj +* d3=answer, d0=rem + move.l %d0,%d1 + move.l %d3,%d0 + move.l %a2,%d3 /* restore d3 */ + rts + diff --git a/tests/sprite_test/builtit.sh b/tests/sprite_test/builtit.sh new file mode 100755 index 0000000..d33a7c7 --- /dev/null +++ b/tests/sprite_test/builtit.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +CURDIR=${PWD} +cd ../.. && make clean && make install && cd ${CURDIR} && make clean && make && gens out.bin diff --git a/tests/sprite_test/main.c b/tests/sprite_test/main.c new file mode 100644 index 0000000..632fa2e --- /dev/null +++ b/tests/sprite_test/main.c @@ -0,0 +1,139 @@ +#include "blast.h" +//#include "images.h" +//#include "terrain_map1.h" + +//u16 terrain_tile_offset; +//blastmap terrain1map; + +char str[10]; + +#define SPR_NBTILES 4 //tiles needed for our sprite + +//const is used to keep tile in ROM, not in RAM +const u32 spriteTiles[SPR_NBTILES*8]= +{ + 0x00001111, //Tile Top Left + 0x00001111, + 0x00111144, + 0x00111144, + 0x11112244, + 0x11112244, + 0x11112244, + 0x11112244, + + 0x11112222, //Tile Bottom Left + 0x11112222, + 0x11112222, + 0x11112222, + 0x00111122, + 0x00111122, + 0x00001111, + 0x00001111, + + 0x11110000, //Tile Top Right + 0x11110000, + 0x44111100, + 0x44111100, + 0x44221111, + 0x44221111, + 0x44221111, + 0x44221111, + + 0x22221111, //Tile Bottom Right + 0x22221111, + 0x22221111, + 0x22221111, + 0x22111100, + 0x22111100, + 0x11110000, + 0x11110000 +}; + +#define DEBUG +#undef DEBUG +int main( ) +{ + spritedef mySprite; + u16 sprite_idx = 0;; + //u8* colls; + u16 sprite_bmp_offset = 1; + + blast_init(); + + //ind = TILE_USERINDEX+sprite_bmp_offset; + + //uintToStr(terrain1.tileset->compression, str, 3); + //VDP_drawText(str, 5, 5); + + u16 ind = TILE_USERINDEX; + //VDP_drawImageEx(PLAN_B, &terrain1, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE); + + /* + VDP_loadTileData(terrain1.tileset->tiles, + TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, ind), + terrain1.tileset->numTile, 0); + //VDP_setMap(PLAN_B, terrain1.map, ind, 0, 0); + VDP_loadTileSet((TileSet*)terrain1.tileset, ind & TILE_INDEX_MASK, TRUE); + blastmap_init(&terrain1map, &terrain1_map, (u16*)terrain1.map->tilemap, ind, PLAN_B); + load_visible_map(&terrain1map,0,0); + + + + */ + + //VDP_setPalette(PAL0, (u16*)terrain1.palette->data); + + //ind += terrain1.tileset->numTile; + //terrain_tile_offset = ind; + + //VDP_drawText(str, 5, 5); + + //VDP_loadTileSet(&(terrain1.tileset), ind, COMPRESSION_NONE); + //ind += terrain1.tileset->numTile; + //terrain_tile_offset = ind; + + /* + terrain_tile_offset = load_bmp( + (u32*) terrain1.tileset->tiles, + terrain1.map->w, + terrain1.map->h + ); + */ +#ifdef DEBUG + terrain_tile_offset = load_img(&terrain1); + VDP_setPalette(PAL0, (u16*)terrain1.palette->data); + + blastmap_init(&terrain1map, &terrain1_map, (u16*)terrain1.tilemap->tilemap, terrain_tile_offset, BG_A); + load_visible_map(&terrain1map,0,0); + + uintToStr(terrain1.tileset->numTile,str,3); + +#endif + VDP_drawText("Sprite Test", 1, 1); + sprite_bmp_offset = load_tile( + (u32*) spriteTiles, + 32, + 8 + ); + + sprite_idx = sprite_init( + &mySprite, + sprite_bmp_offset, + 1, + 0, + 64, + 2, + 2, + PAL0 + ); + + while(1) + { + //sprite_down(&mySprite, 1, 72); + mySprite.posy++; + VDP_waitVSync(); + //wait_vsync(); + + } + return 0; +}