mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-11-14 06:45:09 +01:00
This commit is contained in:
commit
4016fa1adc
@ -95,6 +95,7 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke)
|
|||||||
* improved Mode 5 sprites rendering timings (fixes "Overdrive" demo)
|
* improved Mode 5 sprites rendering timings (fixes "Overdrive" demo)
|
||||||
* improved FIFO timings accuracy (fixes "Overdrive" Demo)
|
* improved FIFO timings accuracy (fixes "Overdrive" Demo)
|
||||||
* improved H-Counter accuracy in H32 mode
|
* improved H-Counter accuracy in H32 mode
|
||||||
|
* improved VDP status timing accuracy
|
||||||
* improved accuracy of Master System color palette brightness range (verified against real hardware)
|
* improved accuracy of Master System color palette brightness range (verified against real hardware)
|
||||||
* fixed misaligned buffer writes in Mode 4 when -DALIGN_LONG option is used
|
* fixed misaligned buffer writes in Mode 4 when -DALIGN_LONG option is used
|
||||||
* fixed alpha channel for 15-bit (RGB555) and 32-bit (RGB888) color support
|
* fixed alpha channel for 15-bit (RGB555) and 32-bit (RGB888) color support
|
||||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 3.2 MiB After Width: | Height: | Size: 3.2 MiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 MiB After Width: | Height: | Size: 3.3 MiB |
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* Mega Drive cartridge hardware support
|
* Mega Drive cartridge hardware support
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2015 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2007-2016 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Many cartridge protections were initially documented by Haze
|
* Many cartridge protections were initially documented by Haze
|
||||||
* (http://haze.mameworld.info/)
|
* (http://haze.mameworld.info/)
|
||||||
@ -44,7 +44,6 @@
|
|||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "eeprom_i2c.h"
|
#include "eeprom_i2c.h"
|
||||||
#include "eeprom_spi.h"
|
#include "eeprom_spi.h"
|
||||||
#include "gamepad.h"
|
|
||||||
|
|
||||||
/* Cart database entry */
|
/* Cart database entry */
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -674,7 +673,7 @@ void md_cart_init(void)
|
|||||||
}
|
}
|
||||||
else if (cart.romsize > 0x400000)
|
else if (cart.romsize > 0x400000)
|
||||||
{
|
{
|
||||||
/* assume linear ROM mapper without bankswitching (max. 10MB) */
|
/* assume linear ROM mapping by default (max. 10MB) */
|
||||||
for (i=0x40; i<0xA0; i++)
|
for (i=0x40; i<0xA0; i++)
|
||||||
{
|
{
|
||||||
m68k.memory_map[i].base = cart.rom + (i<<16);
|
m68k.memory_map[i].base = cart.rom + (i<<16);
|
||||||
@ -1614,16 +1613,23 @@ static uint32 mapper_radica_r(uint32 address)
|
|||||||
|
|
||||||
static void default_time_w(uint32 address, uint32 data)
|
static void default_time_w(uint32 address, uint32 data)
|
||||||
{
|
{
|
||||||
|
/* enable multi-game cartridge mapper by default */
|
||||||
if (address < 0xa13040)
|
if (address < 0xa13040)
|
||||||
{
|
{
|
||||||
/* unlicensed cartridges mapper (default) */
|
|
||||||
mapper_64k_multi_w(address);
|
mapper_64k_multi_w(address);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* official cartridges mapper (default) */
|
/* enable "official" cartridge mapper by default */
|
||||||
|
if (address > 0xa130f1)
|
||||||
|
{
|
||||||
|
mapper_512k_w(address, data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
mapper_sega_w(data);
|
mapper_sega_w(data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* Mega Drive cartridge hardware support
|
* Mega Drive cartridge hardware support
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2015 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2007-2016 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Most cartridge protections were initially documented by Haze
|
* Most cartridge protections were initially documented by Haze
|
||||||
* (http://haze.mameworld.info/)
|
* (http://haze.mameworld.info/)
|
||||||
@ -76,12 +76,12 @@ typedef struct
|
|||||||
/* Cartridge type */
|
/* Cartridge type */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8 rom[MAXROMSIZE]; /* ROM area */
|
|
||||||
uint8 *base; /* ROM base (saved for OS/Cartridge ROM swap) */
|
uint8 *base; /* ROM base (saved for OS/Cartridge ROM swap) */
|
||||||
uint32 romsize; /* ROM size */
|
uint32 romsize; /* ROM size */
|
||||||
uint32 mask; /* ROM mask */
|
uint32 mask; /* ROM mask */
|
||||||
uint8 special; /* Lock-On, J-Cart or SMS 3-D glasses hardware */
|
uint8 special; /* custom external hardware (Lock-On, J-Cart, 3-D glasses, Terebi Oekaki,...) */
|
||||||
cart_hw_t hw; /* Extra mapping hardware */
|
cart_hw_t hw; /* cartridge internal hardware */
|
||||||
|
uint8 rom[MAXROMSIZE]; /* ROM area */
|
||||||
} md_cart_t;
|
} md_cart_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* CD compatible ROM/RAM cartridge support
|
* CD compatible ROM/RAM cartridge support
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2015 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2012-2016 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* CD compatible ROM/RAM cartridge support
|
* CD compatible ROM/RAM cartridge support
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2015 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2012-2016 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -40,7 +40,7 @@
|
|||||||
/* CD compatible ROM/RAM cartridge */
|
/* CD compatible ROM/RAM cartridge */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8 area[0x840000]; /* cartridge ROM/RAM area (max. 8MB ROM / 64KB backup memory + Pro Action Replay 128KB ROM / 64KB RAM) */
|
uint8 area[0x840080]; /* cartridge ROM/RAM area (max. 8MB ROM + 64KB backup memory + Pro Action Replay 128KB ROM / 64KB RAM + cartridge infos) */
|
||||||
uint8 boot; /* cartridge boot mode (0x00: boot from CD with ROM/RAM cartridge enabled, 0x40: boot from ROM cartridge with CD enabled) */
|
uint8 boot; /* cartridge boot mode (0x00: boot from CD with ROM/RAM cartridge enabled, 0x40: boot from ROM cartridge with CD enabled) */
|
||||||
uint8 id; /* RAM cartridge ID (related to RAM size, 0 if disabled) */
|
uint8 id; /* RAM cartridge ID (related to RAM size, 0 if disabled) */
|
||||||
uint8 prot; /* RAM cartridge write protection */
|
uint8 prot; /* RAM cartridge write protection */
|
||||||
|
@ -423,6 +423,9 @@ void system_frame_gen(int do_skip)
|
|||||||
bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1);
|
bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* active screen width */
|
||||||
|
bitmap.viewport.w = 256 + ((reg[12] & 0x01) << 6);
|
||||||
|
|
||||||
/* check viewport changes */
|
/* check viewport changes */
|
||||||
if (bitmap.viewport.h != bitmap.viewport.oh)
|
if (bitmap.viewport.h != bitmap.viewport.oh)
|
||||||
{
|
{
|
||||||
@ -478,12 +481,6 @@ void system_frame_gen(int do_skip)
|
|||||||
/* refresh inputs just before VINT (Warriors of Eternal Sun) */
|
/* refresh inputs just before VINT (Warriors of Eternal Sun) */
|
||||||
osd_input_update();
|
osd_input_update();
|
||||||
|
|
||||||
/* delay between VINT flag & Vertical Interrupt (Ex-Mutants, Tyrant) */
|
|
||||||
m68k_run(588);
|
|
||||||
|
|
||||||
/* set VINT flag */
|
|
||||||
status |= 0x80;
|
|
||||||
|
|
||||||
/* delay between VBLANK flag & Vertical Interrupt (Dracula, OutRunners, VR Troopers) */
|
/* delay between VBLANK flag & Vertical Interrupt (Dracula, OutRunners, VR Troopers) */
|
||||||
m68k_run(788);
|
m68k_run(788);
|
||||||
if (zstate == 1)
|
if (zstate == 1)
|
||||||
@ -495,6 +492,9 @@ void system_frame_gen(int do_skip)
|
|||||||
Z80.cycles = 788;
|
Z80.cycles = 788;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set VINT flag */
|
||||||
|
status |= 0x80;
|
||||||
|
|
||||||
/* Vertical Interrupt */
|
/* Vertical Interrupt */
|
||||||
vint_pending = 0x20;
|
vint_pending = 0x20;
|
||||||
if (reg[1] & 0x20)
|
if (reg[1] & 0x20)
|
||||||
@ -792,6 +792,9 @@ void system_frame_scd(int do_skip)
|
|||||||
bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1);
|
bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* active screen width */
|
||||||
|
bitmap.viewport.w = 256 + ((reg[12] & 0x01) << 6);
|
||||||
|
|
||||||
/* check viewport changes */
|
/* check viewport changes */
|
||||||
if (bitmap.viewport.h != bitmap.viewport.oh)
|
if (bitmap.viewport.h != bitmap.viewport.oh)
|
||||||
{
|
{
|
||||||
@ -847,12 +850,6 @@ void system_frame_scd(int do_skip)
|
|||||||
/* refresh inputs just before VINT */
|
/* refresh inputs just before VINT */
|
||||||
osd_input_update();
|
osd_input_update();
|
||||||
|
|
||||||
/* delay between VINT flag & Vertical Interrupt (Ex-Mutants, Tyrant) */
|
|
||||||
m68k_run(588);
|
|
||||||
|
|
||||||
/* set VINT flag */
|
|
||||||
status |= 0x80;
|
|
||||||
|
|
||||||
/* delay between VBLANK flag & Vertical Interrupt (Dracula, OutRunners, VR Troopers) */
|
/* delay between VBLANK flag & Vertical Interrupt (Dracula, OutRunners, VR Troopers) */
|
||||||
m68k_run(788);
|
m68k_run(788);
|
||||||
if (zstate == 1)
|
if (zstate == 1)
|
||||||
@ -864,6 +861,9 @@ void system_frame_scd(int do_skip)
|
|||||||
Z80.cycles = 788;
|
Z80.cycles = 788;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set VINT flag */
|
||||||
|
status |= 0x80;
|
||||||
|
|
||||||
/* Vertical Interrupt */
|
/* Vertical Interrupt */
|
||||||
vint_pending = 0x20;
|
vint_pending = 0x20;
|
||||||
if (reg[1] & 0x20)
|
if (reg[1] & 0x20)
|
||||||
@ -1181,6 +1181,9 @@ void system_frame_sms(int do_skip)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* active screen width */
|
||||||
|
bitmap.viewport.w = 256 + ((reg[12] & 0x01) << 6);
|
||||||
|
|
||||||
/* check viewport changes */
|
/* check viewport changes */
|
||||||
if (bitmap.viewport.h != bitmap.viewport.oh)
|
if (bitmap.viewport.h != bitmap.viewport.oh)
|
||||||
{
|
{
|
||||||
|
@ -1134,6 +1134,9 @@ unsigned int vdp_68k_ctrl_r(unsigned int cycles)
|
|||||||
{
|
{
|
||||||
unsigned int temp;
|
unsigned int temp;
|
||||||
|
|
||||||
|
/* Cycle-accurate VDP status read (68k read cycle takes four CPU cycles i.e 28 Mcycles) */
|
||||||
|
cycles += 4 * 7;
|
||||||
|
|
||||||
/* Update FIFO status flags if not empty */
|
/* Update FIFO status flags if not empty */
|
||||||
if (fifo_write_cnt)
|
if (fifo_write_cnt)
|
||||||
{
|
{
|
||||||
@ -1160,14 +1163,25 @@ unsigned int vdp_68k_ctrl_r(unsigned int cycles)
|
|||||||
/* Clear SOVR & SCOL flags */
|
/* Clear SOVR & SCOL flags */
|
||||||
status &= 0xFF9F;
|
status &= 0xFF9F;
|
||||||
|
|
||||||
/* Display OFF: VBLANK flag is set */
|
/* VBLANK flag is set when display is disabled */
|
||||||
if (!(reg[1] & 0x40))
|
if (!(reg[1] & 0x40))
|
||||||
{
|
{
|
||||||
temp |= 0x08;
|
temp |= 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* HBLANK flag (Sonic 3 and Sonic 2 "VS Modes", Lemmings 2, Mega Turrican, V.R Troopers, Gouketsuji Ichizoku,...) */
|
/* Cycle-accurate VINT flag (Ex-Mutants, Tyrant / Mega-Lo-Mania) */
|
||||||
/* NB: this is not 100% accurate and need to be verified on real hardware */
|
/* this allows VINT flag to be read just before vertical interrupt is being triggered */
|
||||||
|
if ((v_counter == bitmap.viewport.h) && (cycles >= (mcycles_vdp + 788)))
|
||||||
|
{
|
||||||
|
/* check Z80 interrupt state to assure VINT has not already been triggered (and flag cleared) */
|
||||||
|
if (Z80.irq_state != ASSERT_LINE)
|
||||||
|
{
|
||||||
|
temp |= 0x80;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cycle-accurate HBLANK flag (Sonic 3 & Sonic 2 "VS Modes", Bugs Bunny Double Trouble, Lemmings 2, Mega Turrican, V.R Troopers, Gouketsuji Ichizoku,...) */
|
||||||
|
/* NB: this is not 100% accurate (see hvc.h for horizontal events timings in H32 and H40 mode) but is close enough to make no noticeable difference for games */
|
||||||
if ((cycles % MCYCLES_PER_LINE) < 588)
|
if ((cycles % MCYCLES_PER_LINE) < 588)
|
||||||
{
|
{
|
||||||
temp |= 0x04;
|
temp |= 0x04;
|
||||||
@ -1932,8 +1946,8 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles)
|
|||||||
/* Update clipping */
|
/* Update clipping */
|
||||||
window_clip(reg[17], 1);
|
window_clip(reg[17], 1);
|
||||||
|
|
||||||
/* Update active display width & max sprite pixels per line*/
|
/* Update max sprite pixels per line*/
|
||||||
max_sprite_pixels = bitmap.viewport.w = 320;
|
max_sprite_pixels = 320;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1949,15 +1963,30 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles)
|
|||||||
/* Update clipping */
|
/* Update clipping */
|
||||||
window_clip(reg[17], 0);
|
window_clip(reg[17], 0);
|
||||||
|
|
||||||
/* Update active display width & max sprite pixels per line*/
|
/* Update max sprite pixels per line*/
|
||||||
max_sprite_pixels = bitmap.viewport.w = 256;
|
max_sprite_pixels = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Active display width modified during HBLANK (Bugs Bunny Double Trouble) */
|
if (v_counter >= bitmap.viewport.h)
|
||||||
if ((v_counter < bitmap.viewport.h) && (reg[1] & 0x40) && (cycles <= (mcycles_vdp + 860)))
|
|
||||||
{
|
{
|
||||||
/* Redraw entire line */
|
/* Active screen width modified during VBLANK will be applied on upcoming frame */
|
||||||
render_line(v_counter);
|
bitmap.viewport.w = max_sprite_pixels;
|
||||||
|
}
|
||||||
|
else if ((v_counter == 0) && (cycles <= (mcycles_vdp + 860)))
|
||||||
|
{
|
||||||
|
/* Active screen width modified during first line HBLANK (Bugs Bunny in Double Trouble) */
|
||||||
|
bitmap.viewport.w = max_sprite_pixels;
|
||||||
|
|
||||||
|
/* Redraw first line */
|
||||||
|
render_line(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Screen width changes during active display (Golden Axe 3 intro, Ultraverse Prime) */
|
||||||
|
/* should be applied on next frame since backend rendered framebuffer width is fixed */
|
||||||
|
/* and can not be modified mid-frame. This is not 100% accurate but games generally */
|
||||||
|
/* do this where the screen is blanked so it is likely unnoticeable. */
|
||||||
|
bitmap.viewport.changed |= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* IPL font engine (using GX rendering)
|
* IPL font engine (using GX rendering)
|
||||||
*
|
*
|
||||||
* Copyright Eke-Eke (2009-2015)
|
* Copyright Eke-Eke (2009-2016)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -52,6 +52,7 @@ typedef struct _yay0header {
|
|||||||
|
|
||||||
static u8 *fontImage;
|
static u8 *fontImage;
|
||||||
static u8 *fontTexture;
|
static u8 *fontTexture;
|
||||||
|
static GXTexObj fontTexObj;
|
||||||
static void *ipl_fontarea;
|
static void *ipl_fontarea;
|
||||||
static sys_fontheader *fontHeader;
|
static sys_fontheader *fontHeader;
|
||||||
static u8 font_size[256];
|
static u8 font_size[256];
|
||||||
@ -205,12 +206,7 @@ static void GetFontTexel(s32 c,void *image,s32 pos,s32 stride)
|
|||||||
|
|
||||||
static void DrawChar(unsigned char c, int xpos, int ypos, int size, GXColor color)
|
static void DrawChar(unsigned char c, int xpos, int ypos, int size, GXColor color)
|
||||||
{
|
{
|
||||||
/* reintialize texture object */
|
/* get font texture data */
|
||||||
GXTexObj texobj;
|
|
||||||
GX_InitTexObj(&texobj, fontTexture, fontHeader->cell_width, fontHeader->cell_height, GX_TF_I4, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
|
||||||
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
|
||||||
|
|
||||||
/* reinitialize font texture data */
|
|
||||||
memset(fontTexture,0,fontHeader->cell_width * fontHeader->cell_height / 2);
|
memset(fontTexture,0,fontHeader->cell_width * fontHeader->cell_height / 2);
|
||||||
GetFontTexel(c,fontTexture,0,fontHeader->cell_width/2);
|
GetFontTexel(c,fontTexture,0,fontHeader->cell_width/2);
|
||||||
DCStoreRange(fontTexture, fontHeader->cell_width * fontHeader->cell_height / 2);
|
DCStoreRange(fontTexture, fontHeader->cell_width * fontHeader->cell_height / 2);
|
||||||
@ -290,6 +286,9 @@ int FONT_Init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* initialize texture object */
|
||||||
|
GX_InitTexObj(&fontTexObj, fontTexture, fontHeader->cell_width, fontHeader->cell_height, GX_TF_I4, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,6 +304,8 @@ int FONT_write(char *string, int size, int x, int y, int max_width, GXColor colo
|
|||||||
{
|
{
|
||||||
int w, ox;
|
int w, ox;
|
||||||
|
|
||||||
|
GX_LoadTexObj(&fontTexObj, GX_TEXMAP0);
|
||||||
|
|
||||||
x -= (vmode->fbWidth / 2);
|
x -= (vmode->fbWidth / 2);
|
||||||
y -= (vmode->efbHeight / 2);
|
y -= (vmode->efbHeight / 2);
|
||||||
|
|
||||||
@ -336,6 +337,8 @@ int FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor colo
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int w = 0;
|
int w = 0;
|
||||||
|
|
||||||
|
GX_LoadTexObj(&fontTexObj, GX_TEXMAP0);
|
||||||
|
|
||||||
while (string[i] && (string[i] != '\n'))
|
while (string[i] && (string[i] != '\n'))
|
||||||
{
|
{
|
||||||
w += (font_size[(u8)string[i++]] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth);
|
w += (font_size[(u8)string[i++]] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth);
|
||||||
@ -370,6 +373,8 @@ int FONT_alignRight(char *string, int size, int x, int y, GXColor color)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int w = 0;
|
int w = 0;
|
||||||
|
|
||||||
|
GX_LoadTexObj(&fontTexObj, GX_TEXMAP0);
|
||||||
|
|
||||||
while (string[i] && (string[i] != '\n'))
|
while (string[i] && (string[i] != '\n'))
|
||||||
{
|
{
|
||||||
w += (font_size[(u8)string[i++]] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth);
|
w += (font_size[(u8)string[i++]] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* IPL font engine (using GX rendering)
|
* IPL font engine (using GX rendering)
|
||||||
*
|
*
|
||||||
* Copyright Eke-Eke (2009-2015)
|
* Copyright Eke-Eke (2009-2016)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Genesis Plus GX video & rendering support
|
* Genesis Plus GX video & rendering support
|
||||||
*
|
*
|
||||||
* Copyright Eke-Eke (2007-2015), based on original work from Softdev (2006)
|
* Copyright Eke-Eke (2007-2016), based on original work from Softdev (2006)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -77,6 +77,7 @@ static u8 gp_fifo[GX_FIFO_MINSIZE] ATTRIBUTE_ALIGN(32);
|
|||||||
static u32 vwidth, vheight;
|
static u32 vwidth, vheight;
|
||||||
static gx_texture *crosshair[2];
|
static gx_texture *crosshair[2];
|
||||||
static gx_texture *cd_leds[2][2];
|
static gx_texture *cd_leds[2][2];
|
||||||
|
static GXTexObj screenTexObj;
|
||||||
|
|
||||||
/*** Framebuffers ***/
|
/*** Framebuffers ***/
|
||||||
static u32 *xfb;
|
static u32 *xfb;
|
||||||
@ -342,7 +343,7 @@ static camera cam =
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*** GX Display List ***/
|
/*** GX Display List ***/
|
||||||
static u8 d_list[32] ATTRIBUTE_ALIGN(32) =
|
static u8 screenDisplayList[32] ATTRIBUTE_ALIGN(32) =
|
||||||
{
|
{
|
||||||
GX_QUADS | GX_VTXFMT0, /* textured quad rendering (Vertex Format 0) */
|
GX_QUADS | GX_VTXFMT0, /* textured quad rendering (Vertex Format 0) */
|
||||||
0x00, 0x04, /* one quad = 4x vertex */
|
0x00, 0x04, /* one quad = 4x vertex */
|
||||||
@ -434,9 +435,6 @@ static void gxStart(void)
|
|||||||
guLookAt(view, &cam.pos, &cam.up, &cam.view);
|
guLookAt(view, &cam.pos, &cam.up, &cam.view);
|
||||||
GX_LoadPosMtxImm(view, GX_PNMTX0);
|
GX_LoadPosMtxImm(view, GX_PNMTX0);
|
||||||
GX_Flush();
|
GX_Flush();
|
||||||
|
|
||||||
/* GX rendering callback */
|
|
||||||
GX_SetDrawDoneCallback(gx_callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset GX rendering */
|
/* Reset GX rendering */
|
||||||
@ -462,6 +460,9 @@ static void gxResetRendering(u8 type)
|
|||||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||||
GX_SetNumTexGens(1);
|
GX_SetNumTexGens(1);
|
||||||
GX_SetNumChans(1);
|
GX_SetNumChans(1);
|
||||||
|
|
||||||
|
/* disable GX rendering callback */
|
||||||
|
GX_SetDrawDoneCallback(NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -480,6 +481,9 @@ static void gxResetRendering(u8 type)
|
|||||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL);
|
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL);
|
||||||
GX_SetNumTexGens(1);
|
GX_SetNumTexGens(1);
|
||||||
GX_SetNumChans(0);
|
GX_SetNumChans(0);
|
||||||
|
|
||||||
|
/* enable GX rendering callback */
|
||||||
|
GX_SetDrawDoneCallback(gx_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
GX_Flush();
|
GX_Flush();
|
||||||
@ -704,10 +708,7 @@ static void gxDrawCrosshair(gx_texture *texture, int x, int y)
|
|||||||
y = (((y + bitmap.viewport.y) * ywidth) / (bitmap.viewport.h+2*bitmap.viewport.y)) + square[7] - h/2;
|
y = (((y + bitmap.viewport.y) * ywidth) / (bitmap.viewport.h+2*bitmap.viewport.y)) + square[7] - h/2;
|
||||||
|
|
||||||
/* load texture object */
|
/* load texture object */
|
||||||
GXTexObj texObj;
|
GX_LoadTexObj(&texture->texObj, GX_TEXMAP0);
|
||||||
GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
|
||||||
GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4);
|
|
||||||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
/* Draw textured quad */
|
/* Draw textured quad */
|
||||||
@ -746,10 +747,7 @@ static void gxDrawCdLeds(gx_texture *texture_l, gx_texture *texture_r)
|
|||||||
int y = (((bitmap.viewport.y + bitmap.viewport.h - 4) * ywidth) / vheight) + square[7] - h;
|
int y = (((bitmap.viewport.y + bitmap.viewport.h - 4) * ywidth) / vheight) + square[7] - h;
|
||||||
|
|
||||||
/* load left screen texture */
|
/* load left screen texture */
|
||||||
GXTexObj texObj;
|
GX_LoadTexObj(&texture_l->texObj, GX_TEXMAP0);
|
||||||
GX_InitTexObj(&texObj, texture_l->data, texture_l->width, texture_l->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
|
||||||
GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4);
|
|
||||||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
/* Draw textured quad */
|
/* Draw textured quad */
|
||||||
@ -769,9 +767,7 @@ static void gxDrawCdLeds(gx_texture *texture_l, gx_texture *texture_r)
|
|||||||
GX_End();
|
GX_End();
|
||||||
|
|
||||||
/* load right screen texture */
|
/* load right screen texture */
|
||||||
GX_InitTexObj(&texObj, texture_r->data, texture_r->width, texture_r->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
GX_LoadTexObj(&texture_r->texObj, GX_TEXMAP0);
|
||||||
GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4);
|
|
||||||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
/* Draw textured quad */
|
/* Draw textured quad */
|
||||||
@ -839,10 +835,7 @@ void gxDrawTexture(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha)
|
|||||||
if (texture->data)
|
if (texture->data)
|
||||||
{
|
{
|
||||||
/* load texture object */
|
/* load texture object */
|
||||||
GXTexObj texObj;
|
GX_LoadTexObj(&texture->texObj, GX_TEXMAP0);
|
||||||
GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
|
||||||
GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); /* does this really change anything ? */
|
|
||||||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
/* vertex coordinate */
|
/* vertex coordinate */
|
||||||
@ -874,10 +867,7 @@ void gxDrawTextureRotate(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, f32 an
|
|||||||
if (texture->data)
|
if (texture->data)
|
||||||
{
|
{
|
||||||
/* load texture object */
|
/* load texture object */
|
||||||
GXTexObj texObj;
|
GX_LoadTexObj(&texture->texObj, GX_TEXMAP0);
|
||||||
GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
|
||||||
GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4);
|
|
||||||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
/* vertex coordinate */
|
/* vertex coordinate */
|
||||||
@ -961,9 +951,7 @@ void gxDrawScreenshot(u8 alpha)
|
|||||||
if (!rmode) return;
|
if (!rmode) return;
|
||||||
|
|
||||||
/* get current game screen texture */
|
/* get current game screen texture */
|
||||||
GXTexObj texobj;
|
GX_LoadTexObj(&screenTexObj, GX_TEXMAP0);
|
||||||
GX_InitTexObj(&texobj, bitmap.data, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
|
||||||
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
/* get current aspect ratio */
|
/* get current aspect ratio */
|
||||||
@ -1010,9 +998,7 @@ void gxDrawScreenshot(u8 alpha)
|
|||||||
void gxCopyScreenshot(gx_texture *texture)
|
void gxCopyScreenshot(gx_texture *texture)
|
||||||
{
|
{
|
||||||
/* retrieve gamescreen texture */
|
/* retrieve gamescreen texture */
|
||||||
GXTexObj texobj;
|
GX_LoadTexObj(&screenTexObj, GX_TEXMAP0);
|
||||||
GX_InitTexObj(&texobj, bitmap.data, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
|
||||||
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
/* scale texture to EFB width */
|
/* scale texture to EFB width */
|
||||||
@ -1054,7 +1040,7 @@ void gxCopyScreenshot(gx_texture *texture)
|
|||||||
/* GX_PixModeSync is only useful if GX_ command follows */
|
/* GX_PixModeSync is only useful if GX_ command follows */
|
||||||
/* we use dummy GX commands to stall CPU execution */
|
/* we use dummy GX commands to stall CPU execution */
|
||||||
GX_PixModeSync();
|
GX_PixModeSync();
|
||||||
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
GX_LoadTexObj(&screenTexObj, GX_TEXMAP0);
|
||||||
GX_InvalidateTexAll();
|
GX_InvalidateTexAll();
|
||||||
GX_Flush();
|
GX_Flush();
|
||||||
DCStoreRange(texture->data, texture->width * texture->height * 4);
|
DCStoreRange(texture->data, texture->width * texture->height * 4);
|
||||||
@ -1228,7 +1214,7 @@ gx_texture *gxTextureOpenPNG(const u8 *png_data, FILE *png_file)
|
|||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
free(row_pointers);
|
free(row_pointers);
|
||||||
|
|
||||||
/* initialize texture */
|
/* allocate texture */
|
||||||
gx_texture *texture = (gx_texture *)memalign(32, sizeof(gx_texture));
|
gx_texture *texture = (gx_texture *)memalign(32, sizeof(gx_texture));
|
||||||
if (!texture)
|
if (!texture)
|
||||||
{
|
{
|
||||||
@ -1236,7 +1222,7 @@ gx_texture *gxTextureOpenPNG(const u8 *png_data, FILE *png_file)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize texture data */
|
/* allocate texture data */
|
||||||
texture->data = memalign(32, stride * height);
|
texture->data = memalign(32, stride * height);
|
||||||
if (!texture->data)
|
if (!texture->data)
|
||||||
{
|
{
|
||||||
@ -1245,11 +1231,15 @@ gx_texture *gxTextureOpenPNG(const u8 *png_data, FILE *png_file)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* initialize texture */
|
||||||
memset(texture->data, 0, stride * height);
|
memset(texture->data, 0, stride * height);
|
||||||
texture->width = width;
|
texture->width = width;
|
||||||
texture->height = height;
|
texture->height = height;
|
||||||
texture->format = GX_TF_RGBA8;
|
texture->format = GX_TF_RGBA8;
|
||||||
|
|
||||||
|
/* initialize GX texture object */
|
||||||
|
GX_InitTexObj(&texture->texObj, texture->data, width, height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||||
|
/*GX_InitTexObjLOD(&texture->texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4);*/
|
||||||
/* encode to GX_TF_RGBA8 format (4x4 pixels paired titles) */
|
/* encode to GX_TF_RGBA8 format (4x4 pixels paired titles) */
|
||||||
u16 *dst_ar = (u16 *)(texture->data);
|
u16 *dst_ar = (u16 *)(texture->data);
|
||||||
u16 *dst_gb = (u16 *)(texture->data + 32);
|
u16 *dst_gb = (u16 *)(texture->data + 32);
|
||||||
@ -1732,17 +1722,16 @@ int gx_video_Update(int status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* initialize texture object */
|
/* initialize texture object */
|
||||||
GXTexObj texobj;
|
GX_InitTexObj(&screenTexObj, bitmap.data, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||||
GX_InitTexObj(&texobj, bitmap.data, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
|
||||||
|
|
||||||
/* configure texture filtering */
|
/* configure texture filtering */
|
||||||
if (!config.bilinear)
|
if (!config.bilinear)
|
||||||
{
|
{
|
||||||
GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1);
|
GX_InitTexObjLOD(&screenTexObj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load texture object */
|
/* load texture object */
|
||||||
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
GX_LoadTexObj(&screenTexObj, GX_TEXMAP0);
|
||||||
|
|
||||||
/* update rendering mode */
|
/* update rendering mode */
|
||||||
if (config.render)
|
if (config.render)
|
||||||
@ -1775,7 +1764,7 @@ int gx_video_Update(int status)
|
|||||||
drawDone = 0;
|
drawDone = 0;
|
||||||
|
|
||||||
/* render textured quad */
|
/* render textured quad */
|
||||||
GX_CallDispList(d_list, 32);
|
GX_CallDispList(screenDisplayList, 32);
|
||||||
|
|
||||||
/* on-screen display */
|
/* on-screen display */
|
||||||
if (osd)
|
if (osd)
|
||||||
@ -1838,14 +1827,7 @@ int gx_video_Update(int status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* restore texture object */
|
/* restore texture object */
|
||||||
GXTexObj texobj;
|
GX_LoadTexObj(&screenTexObj, GX_TEXMAP0);
|
||||||
GX_InitTexObj(&texobj, bitmap.data, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
|
||||||
if (!config.bilinear)
|
|
||||||
{
|
|
||||||
GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1);
|
|
||||||
}
|
|
||||||
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
|
||||||
GX_InvalidateTexAll();
|
|
||||||
|
|
||||||
/* restore GX rendering */
|
/* restore GX rendering */
|
||||||
gxResetRendering(0);
|
gxResetRendering(0);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Genesis Plus GX video support
|
* Genesis Plus GX video support
|
||||||
*
|
*
|
||||||
* Copyright Eke-Eke (2007-2015), based on original work from Softdev (2006)
|
* Copyright Eke-Eke (2007-2016), based on original work from Softdev (2006)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -84,6 +84,7 @@
|
|||||||
/* image texture */
|
/* image texture */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
GXTexObj texObj;
|
||||||
u8 *data;
|
u8 *data;
|
||||||
u16 width;
|
u16 width;
|
||||||
u16 height;
|
u16 height;
|
||||||
|
Loading…
Reference in New Issue
Block a user