Skip to content

Commit

Permalink
Update for SGDK 1.51 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
kubilus1 committed Nov 23, 2020
1 parent fa81a07 commit bb61a60
Show file tree
Hide file tree
Showing 35 changed files with 2,978 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
*.o
tags
*bkp*
output.map
/*.s
3 changes: 3 additions & 0 deletions incs/blast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
Expand Down
3 changes: 2 additions & 1 deletion incs/sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions incs/tilemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
42 changes: 32 additions & 10 deletions libs/blast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -45,21 +45,21 @@ void blast_init() {

//VDP_resetSprites();
//VDP_setScreenWidth256();
//VDP_setScreenWidth320();
VDP_setScreenWidth320();

//VDP_setHIntCounter(2);
//VDP_setHInterrupt(1);

//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);
Expand Down Expand Up @@ -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();
}

2 changes: 1 addition & 1 deletion libs/gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions libs/sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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];

Expand Down
30 changes: 21 additions & 9 deletions libs/tilemap.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -495,15 +495,19 @@ void load_map_row(blastmap* bmap, u8 row) {
j,
i,
numtiles_a,
1
1,
1,
CPU
);
VDP_setTileMapDataRect(
bmap->plane,
(u16*)tiles + numtiles_a,
0,
i,
numtiles_b,
1
1,
1,
CPU
);

} else {
Expand All @@ -515,7 +519,9 @@ void load_map_row(blastmap* bmap, u8 row) {
j,
i,
numtiles,
1
1,
1,
CPU
);

}
Expand Down Expand Up @@ -598,15 +604,19 @@ void load_map_col(blastmap* bmap, u8 col) {
i,
j,
1,
numtiles_a
numtiles_a,
1,
CPU
);
VDP_setTileMapDataRect(
bmap->plane,
(u16*)tiles + numtiles_a,
i,
0,
1,
numtiles_b
numtiles_b,
1,
CPU
);
} else {
// Does this handle plane wrap around? NOPE
Expand All @@ -616,7 +626,9 @@ void load_map_col(blastmap* bmap, u8 col) {
i,
j,
1,
numtiles
numtiles,
1,
CPU
);
}
SYS_enableInts();
Expand Down
Loading

0 comments on commit bb61a60

Please sign in to comment.