mirror of
https://github.com/dwsJason/xrick2gs.git
synced 2025-01-21 09:34:23 +00:00
Allocate Video Buffers from the System, and check for errors while doing so
This commit is contained in:
parent
27e73a4dc2
commit
cd76e114c0
@ -99,7 +99,7 @@ extern void sysvid_zoom(S8);
|
||||
extern void sysvid_toggleFullscreen(void);
|
||||
extern void sysvid_setGamePalette(void);
|
||||
extern void sysvid_setPalette(img_color_t *, U16);
|
||||
|
||||
extern void sysvid_wait_vblank();
|
||||
/*
|
||||
* events section
|
||||
*/
|
||||
|
10
src/system.c
10
src/system.c
@ -100,6 +100,14 @@ sys_gettime(void)
|
||||
void
|
||||
sys_sleep(int s)
|
||||
{
|
||||
#ifdef IIGS
|
||||
// on GS we're going to work in ms, also we don't sleep, we just wait
|
||||
while (s > 0)
|
||||
{
|
||||
sysvid_wait_vblank();
|
||||
s -= 16; // Abouy 1/60th of a second
|
||||
}
|
||||
#endif
|
||||
#ifndef IIGS
|
||||
SDL_Delay(s);
|
||||
#endif
|
||||
@ -121,8 +129,10 @@ sys_init(int argc, char **argv)
|
||||
syssnd_init();
|
||||
#endif
|
||||
atexit(sys_shutdown);
|
||||
#ifndef IIGS
|
||||
signal(SIGINT, exit);
|
||||
signal(SIGTERM, exit);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
67
src/sysvid.c
67
src/sysvid.c
@ -26,6 +26,13 @@
|
||||
#include "img.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef IIGS
|
||||
#include <GSOS.h>
|
||||
#include <Memory.h>
|
||||
#include <Orca.h>
|
||||
#include <Misctool.h>
|
||||
#endif
|
||||
|
||||
#ifdef __MSVC__
|
||||
#include <memory.h> /* memset */
|
||||
#endif
|
||||
@ -190,6 +197,48 @@ sysvid_chkvm(void)
|
||||
void
|
||||
sysvid_init(void)
|
||||
{
|
||||
#ifdef IIGS
|
||||
handle hndl; // "generic memory handle"
|
||||
|
||||
// PushLong #0 ;/* Ask Shadowing Screen ($8000 bytes from $01/2000)*/
|
||||
// PushLong #$8000
|
||||
// PushWord myID
|
||||
// PushWord #%11000000_00000011
|
||||
// PushLong #$012000
|
||||
// _NewHandle
|
||||
// PLA
|
||||
// PLA
|
||||
|
||||
// Allocate Bank 01 memory + 4K before and after (25 lines pre flow)
|
||||
// $012000-$019BFF pixel data
|
||||
// $019D00-$019DC7 SCB data
|
||||
// $019E00-$019FFF Clut data
|
||||
// $900 bytes afer, (14 lines buffer on the bottom, which will wreck SCB+CLUT
|
||||
//
|
||||
printf("Allocate Bank $01 memory\n");
|
||||
hndl = NewHandle(0x9600, userid(), 0xC003, (pointer) 0x011000);
|
||||
if (toolerror())
|
||||
{
|
||||
printf("Unable to allocate backpage at 0x012000\n");
|
||||
printf("Game can't run\n");
|
||||
sys_sleep(5000); // Wait 5 seconds
|
||||
exit(1);
|
||||
|
||||
}
|
||||
printf("SUCCESS\n");
|
||||
|
||||
// Allocate Bank E1 memory - Actual Video memory
|
||||
printf("Allocate Bank $E1 memory\n");
|
||||
hndl = NewHandle(0x8000, userid(), 0xC003, (pointer) 0xE12000);
|
||||
if (toolerror())
|
||||
{
|
||||
printf("Unable to allocate display buffer at 0xE12000\n");
|
||||
printf("Game can't run\n");
|
||||
sys_sleep(5000); // Wait 5 seconds
|
||||
exit(1);
|
||||
}
|
||||
printf("SUCCESS\n");
|
||||
#endif
|
||||
#ifndef IIGS
|
||||
SDL_Surface *s;
|
||||
U8 *mask, tpix;
|
||||
@ -405,6 +454,24 @@ sysvid_toggleFullscreen(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void sysvid_wait_vblank()
|
||||
{
|
||||
#ifdef IIGS
|
||||
volatile const S8* VSTATUS = (S8*) 0xC019;
|
||||
|
||||
// While already in vblank wait
|
||||
while ((*VSTATUS & 0x80) == 0)
|
||||
{
|
||||
// Wait for VBLANK to END
|
||||
}
|
||||
while ((*VSTATUS & 0x80) != 0)
|
||||
{
|
||||
// Wait for VBLANK to BEGIN
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
||||
|
||||
|
||||
|
44
src/xrick.c
44
src/xrick.c
@ -18,13 +18,9 @@
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
//extern void waitkey();
|
||||
//extern void fbuffer();
|
||||
|
||||
extern char splash_lz4;
|
||||
|
||||
char *VIDEO = (char*)0xE1C029;
|
||||
|
||||
volatile char *VIDEO = (char*)0xC029;
|
||||
extern int LZ4_Unpack(char* pDest, char* pPackedSource);
|
||||
|
||||
/*
|
||||
@ -33,48 +29,14 @@ extern int LZ4_Unpack(char* pDest, char* pPackedSource);
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
//char *pChar = &testtext;
|
||||
|
||||
printf("Hello from xrick IIgs\n");
|
||||
|
||||
printf("Unpacking Splash!");
|
||||
printf("Unpacking Splash!\n");
|
||||
|
||||
LZ4_Unpack((char*)(0xE12000), &splash_lz4);
|
||||
|
||||
//while (pChar[0])
|
||||
//{
|
||||
// pChar[0]|=0x80;
|
||||
// pChar++;
|
||||
//}
|
||||
|
||||
// printf("%s\n", &testtext);
|
||||
|
||||
// SHR ON
|
||||
*VIDEO|=0xC0;
|
||||
|
||||
|
||||
// waitkey();
|
||||
// fbuffer();
|
||||
|
||||
#if 0
|
||||
handle hndl; /* "generic" handle */
|
||||
/* Create new member array of minimum size. */
|
||||
hndl = NewHandle(1024L, myID, 0xC010, NULL);
|
||||
if (toolerror()) {
|
||||
HandleError(toolerror(), memryErr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// PushLong #0 ;/* Ask Shadowing Screen ($8000 bytes from $01/2000)*/
|
||||
// PushLong #$8000
|
||||
// PushWord myID
|
||||
// PushWord #%11000000_00000011
|
||||
// PushLong #$012000
|
||||
// _NewHandle
|
||||
// PLA
|
||||
// PLA
|
||||
#endif
|
||||
|
||||
// *VIDEO|=0xC0;
|
||||
|
||||
sys_init(argc, argv);
|
||||
if (sysarg_args_data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user