- [NEW] conectat el mem::reset
- [NEW] Break on unknown opcode - [FIX] Solventats mil bugs de pintat del background
This commit is contained in:
+23
-17
@@ -10,6 +10,7 @@
|
||||
namespace gbscreen
|
||||
{
|
||||
uint32_t palette[4] = {
|
||||
//0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF
|
||||
0xFFFFFF, 0xAAAAAA, 0x555555, 0x000000
|
||||
};
|
||||
SDL_Window *win = nullptr;
|
||||
@@ -21,13 +22,13 @@ namespace gbscreen
|
||||
uint32_t t_states_per_scanline = 456;
|
||||
uint32_t vsync_lines = 10;
|
||||
|
||||
uint8_t zoom = 1;
|
||||
uint8_t zoom = 2;
|
||||
bool fullscreen = false;
|
||||
bool full_refresh = true;
|
||||
int fullscreen_scale = 1;
|
||||
SDL_Rect dest_rect;
|
||||
|
||||
uint32_t time=0;
|
||||
//uint32_t time=0;
|
||||
|
||||
uint32_t t_screen = 0;
|
||||
|
||||
@@ -136,33 +137,34 @@ namespace gbscreen
|
||||
const uint8_t LCDC = mem::readMem(0xff40);
|
||||
const uint8_t SCY = mem::readMem(0xff42);
|
||||
const uint8_t SCX = mem::readMem(0xff43);
|
||||
const uint8_t ty = uint8_t(SCY+LY) >> 3;
|
||||
const uint16_t ty = uint8_t(SCY+LY) >> 3;
|
||||
const uint8_t ly = uint8_t(SCY+LY) & 0x7;
|
||||
uint8_t tx = SCX >> 3;
|
||||
uint16_t tx = SCX >> 3;
|
||||
uint8_t ox = SCX & 0x7;
|
||||
|
||||
uint16_t tilemap_address = LCDC&0x8 ? 0x9c00 : 0x9800;
|
||||
tilemap_address += tx + (ty<<5);
|
||||
uint8_t tile = mem::readMem(tilemap_address);
|
||||
uint16_t tile_address = 0x8000;
|
||||
if ( ((LCDC&0x10)==0) && (tile<128) ) tile_address = 0x9000;
|
||||
tile_address = tile_address + (tile<<8);
|
||||
uint16_t base_tilemap_address = LCDC&0x8 ? 0x9c00 : 0x9800;
|
||||
|
||||
int pi = 0;
|
||||
while(true) {
|
||||
uint8_t a = mem::readMem(tile_address++);
|
||||
uint8_t b = mem::readMem(tile_address++);
|
||||
uint16_t tilemap_address = base_tilemap_address + tx + (ty<<5);
|
||||
uint16_t tile = mem::readMem(tilemap_address);
|
||||
uint16_t base_tile_address = 0x8000;
|
||||
if ( ((LCDC&0x10)==0) && (tile<128) ) base_tile_address = 0x9000;
|
||||
uint16_t tile_address = base_tile_address + (tile<<4) + (ly*2);
|
||||
|
||||
uint8_t a = mem::readMem(tile_address);
|
||||
uint8_t b = mem::readMem(tile_address+1);
|
||||
for (int i=0; i<8; ++i) {
|
||||
if (ox==0) {
|
||||
line_buffer[pi++] = (a&0x10 ? 1 : 0) + (b&0x10 ? 2 : 0 );
|
||||
line_buffer[pi++] = (a&0x80 ? 1 : 0) + (b&0x80 ? 2 : 0 );
|
||||
} else {
|
||||
ox--;
|
||||
}
|
||||
a<<1; b<<1;
|
||||
a=a<<1; b=b<<1;
|
||||
if (pi==160) return;
|
||||
}
|
||||
tx = (tx+1)&0x1f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void refresh(const uint32_t dt, const bool full)
|
||||
@@ -176,8 +178,12 @@ namespace gbscreen
|
||||
for (int i=0;i<dt;++i)
|
||||
{
|
||||
// Açò va volcant els pixels del line_buffer en pantalla
|
||||
uint16_t current_pixel = dots_in_scanline-80;
|
||||
if (current_pixel<160) *(ptr_pixel++) = line_buffer[current_pixel];
|
||||
if ( (STAT&0x3)==3) {
|
||||
uint16_t current_pixel = dots_in_scanline-80;
|
||||
if (current_pixel<160) {
|
||||
*(ptr_pixel++) = line_buffer[current_pixel];
|
||||
}
|
||||
}
|
||||
|
||||
// gestió de en quin dot i linea estem, i tot el que ha de passar
|
||||
bool stat_interrupt = false;
|
||||
|
||||
Reference in New Issue
Block a user