mirror of
https://github.com/ogoguel/activegs-ios.git
synced 2024-12-26 10:32:48 +00:00
added ActiveGS_AsmJS test
This commit is contained in:
parent
1c30e57773
commit
a01ef5862f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.DS_Store
|
||||
xcuserdata/
|
||||
ActiveGS_AsmJS/out
|
||||
|
BIN
ActiveGS_AsmJS/Nucleus.2mg
Normal file
BIN
ActiveGS_AsmJS/Nucleus.2mg
Normal file
Binary file not shown.
BIN
ActiveGS_AsmJS/ROM
Normal file
BIN
ActiveGS_AsmJS/ROM
Normal file
Binary file not shown.
64
ActiveGS_AsmJS/config.kegs
Normal file
64
ActiveGS_AsmJS/config.kegs
Normal file
@ -0,0 +1,64 @@
|
||||
# KEGS configuration file version 0.91
|
||||
|
||||
s5d1 = Nucleus.2mg
|
||||
s5d2 = #::
|
||||
|
||||
s6d1 = #::dos33.dsk
|
||||
s6d2 = #::
|
||||
|
||||
s7d1 = #
|
||||
s7d2 = #::
|
||||
s7d3 = #::
|
||||
s7d4 = #::
|
||||
s7d5 = #::
|
||||
s7d6 = #::
|
||||
s7d7 = #::
|
||||
s7d8 = #::
|
||||
s7d9 = #::
|
||||
s7d10 = #::
|
||||
s7d11 = #::
|
||||
s7d12 = #::
|
||||
s7d13 = #::
|
||||
s7d14 = #::
|
||||
s7d15 = #::
|
||||
s7d16 = #::
|
||||
s7d17 = #::
|
||||
s7d18 = #::
|
||||
s7d19 = #::
|
||||
s7d20 = #::
|
||||
s7d21 = #::
|
||||
s7d22 = #::
|
||||
s7d23 = #::
|
||||
s7d24 = #::
|
||||
s7d25 = #::
|
||||
s7d26 = #::
|
||||
s7d27 = #::
|
||||
s7d28 = #::
|
||||
s7d29 = #::
|
||||
s7d30 = #::
|
||||
s7d31 = #::
|
||||
s7d32 = #::
|
||||
|
||||
g_joystick_type = 0
|
||||
g_sim65816.g_limit_speed = 2
|
||||
|
||||
|
||||
bram1[00] = 00 00 00 01 00 00 0d 06 02 01 01 00 01 00 00 00
|
||||
bram1[10] = 00 00 07 06 02 01 01 00 00 00 0f 06 06 00 05 06
|
||||
bram1[20] = 01 00 00 00 00 00 00 01 05 00 00 00 03 02 02 02
|
||||
bram1[30] = 00 00 00 00 00 00 00 00 00 00 01 02 03 04 05 06
|
||||
bram1[40] = 07 00 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
|
||||
bram1[50] = 0e 0f ff ff ff ff ff ff ff 00 ff ff ff ff ff 81
|
||||
bram1[60] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[70] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[80] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[90] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[a0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[b0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[c0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[d0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[e0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[f0] = ff ff ff ff ff ff ff ff ff ff ff ff 3c 77 96 dd
|
||||
|
||||
|
||||
|
51
ActiveGS_AsmJS/makefile
Normal file
51
ActiveGS_AsmJS/makefile
Normal file
@ -0,0 +1,51 @@
|
||||
CC=emcc
|
||||
SOURCES:= ../kegs/Src/adb.cpp \
|
||||
../kegs/Src/async_event.cpp \
|
||||
../kegs/Src/clock.cpp \
|
||||
../kegs/Src/compression.cpp \
|
||||
../kegs/Src/config_generic.cpp \
|
||||
../kegs/Src/dis.cpp \
|
||||
../kegs/Src/driver.cpp \
|
||||
../kegs/Src/engine_c.cpp \
|
||||
../kegs/Src/GraphCounter.cpp \
|
||||
../kegs/Src/iwm.cpp \
|
||||
../kegs/Src/marinetti.cpp \
|
||||
../kegs/Src/moremem.cpp \
|
||||
../kegs/Src/paddles.cpp \
|
||||
../kegs/Src/SaveState.cpp \
|
||||
../kegs/Src/smartport.cpp \
|
||||
../kegs/Src/sound.cpp \
|
||||
../kegs/Src/sound_driver.cpp \
|
||||
../kegs/Src/scc.cpp \
|
||||
../kegs/Src/scc_socket_driver.cpp \
|
||||
../kegs/Src/video.cpp \
|
||||
../kegs/Src/sim65816.cpp \
|
||||
../kegs/Dummy/sounddriver_dummy.cpp \
|
||||
../kegs/Dummy/joystick_dummy.cpp \
|
||||
../Libraries/zlib123/adler32.cpp \
|
||||
../Libraries/zlib123/compress.cpp \
|
||||
../Libraries/zlib123/crc32.cpp \
|
||||
../Libraries/zlib123/deflate.cpp \
|
||||
../Libraries/zlib123/inflate.cpp \
|
||||
../Libraries/zlib123/inftrees.cpp \
|
||||
../Libraries/zlib123/trees.cpp \
|
||||
../Libraries/zlib123/uncompr.cpp \
|
||||
../Libraries/zlib123/zutil.cpp \
|
||||
../Libraries/zlib123/inffast.cpp \
|
||||
../kegs/Console/config_kegs.cpp \
|
||||
../kegs/AsmJS/asmjs_generic.cpp \
|
||||
../kegs/AsmJS/asmjs_console.cpp
|
||||
|
||||
|
||||
LDFLAGS=-O2 --llvm-opts 2
|
||||
OUTPUT=activegs.js
|
||||
|
||||
all: $(SOURCES) $(OUTPUT)
|
||||
|
||||
|
||||
$(OUTPUT): $(SOURCES)
|
||||
$(CC) $(SOURCES) -s TOTAL_MEMORY=33554432 -DKEGS_LITTLE_ENDIAN=1 -DACTIVEGS_NOSAVESTATE=1 -DDO_VERBOSE=0 -DNO_MARINETTI_SUPPORT=1 -O2 -s ASM_JS=1 --embed-file config.kegs --preload-file ROM --preload-file Nucleus.2mg -o out/index.html
|
||||
|
||||
clean:
|
||||
rm $(OUTPUT)
|
||||
rm $(OUTPUT).map
|
1
ActiveGS_AsmJS/test.sh
Normal file
1
ActiveGS_AsmJS/test.sh
Normal file
@ -0,0 +1 @@
|
||||
open -a Google\ Chrome --args --disable-web-security --args --allow-file-access-from-files file://$PWD/out/index.html
|
185
kegs/AsmJS/asmjs_console.cpp
Normal file
185
kegs/AsmJS/asmjs_console.cpp
Normal file
@ -0,0 +1,185 @@
|
||||
/*
|
||||
ActiveGS, Copyright 2004-2016 Olivier Goguel, https://github.com/ogoguel/ActiveGS
|
||||
Based on Kegs, Copyright 2004 Kent Dickey, https://kegs.sourceforge.net
|
||||
This code is covered by the GNU GPL licence
|
||||
*/
|
||||
|
||||
#include "../src/defc.h"
|
||||
#include "../src/driver.h"
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#include <SDL.h>
|
||||
#else
|
||||
#include <sdl/SDL.h>
|
||||
#endif
|
||||
|
||||
extern void kegsinit(void*);
|
||||
extern void kegsshut();
|
||||
|
||||
extern char *g_status_ptrs[MAX_STATUS_LINES];
|
||||
|
||||
|
||||
int
|
||||
win_nonblock_read_stdin(int fd, char *bufptr, int len)
|
||||
{
|
||||
|
||||
/*
|
||||
HANDLE oshandle;
|
||||
DWORD dwret;
|
||||
int ret;
|
||||
|
||||
errno = EAGAIN;
|
||||
oshandle = (HANDLE)_get_osfhandle(fd); // get stdin handle
|
||||
dwret = WaitForSingleObject(oshandle, 1); // wait 1msec for data
|
||||
ret = -1;
|
||||
if(dwret == WAIT_OBJECT_0) {
|
||||
ret = read(fd, bufptr, len);
|
||||
}
|
||||
return ret;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
x_fatal_exit(const char *str)
|
||||
{
|
||||
|
||||
}
|
||||
int
|
||||
x_show_alert(int is_fatal, const char *str)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
int WINAPI WinMain (
|
||||
HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nShowCmd)
|
||||
{
|
||||
return main(0,0);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
extern int kegsmain_init(int argc, char **argv);
|
||||
extern int g_config_control_panel;
|
||||
extern void run_prog_init();
|
||||
extern void run_prog_shut();
|
||||
extern int run_prog_loop();
|
||||
extern void asmjs_video_update();
|
||||
|
||||
void iter()
|
||||
{
|
||||
static int in_iter = false;
|
||||
if (in_iter)
|
||||
{
|
||||
printf("too slow...\n");
|
||||
return ;
|
||||
}
|
||||
in_iter = true;
|
||||
run_prog_loop();
|
||||
asmjs_video_update();
|
||||
in_iter = false;
|
||||
}
|
||||
|
||||
extern void kegs_driver();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
//int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
|
||||
g_driver.init(kegs_driver);
|
||||
|
||||
|
||||
// int ret = kegsmain(argc, argv);
|
||||
kegsmain_init(argc,argv);
|
||||
|
||||
// do go
|
||||
|
||||
|
||||
g_config_control_panel = 0;
|
||||
clear_halt();
|
||||
|
||||
run_prog_init();
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(iter,0,0);
|
||||
#else
|
||||
while(1)
|
||||
iter();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern void add_event_mouse(int _x,int _y, int _state, int _button);
|
||||
extern void simulate_space_event();
|
||||
|
||||
void
|
||||
x_check_system_input_events()
|
||||
{
|
||||
|
||||
int x,y;
|
||||
SDL_PumpEvents();
|
||||
int s = SDL_GetMouseState(&x,&y);
|
||||
int b = s & SDL_BUTTON(1);
|
||||
add_event_mouse(x,y,b,1);
|
||||
|
||||
if (b)
|
||||
{
|
||||
simulate_space_event();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
x_redraw_status_lines()
|
||||
{
|
||||
/*
|
||||
COLORREF oldtextcolor, oldbkcolor;
|
||||
char *buf;
|
||||
int line;
|
||||
int len;
|
||||
int height;
|
||||
int margin;
|
||||
|
||||
height = 16;
|
||||
margin = 0;
|
||||
|
||||
HDC localdc = GetDC(g_hwnd_main); // OG Use on the fly DC
|
||||
oldtextcolor = SetTextColor(localdc, 0);
|
||||
oldbkcolor = SetBkColor(localdc, 0xffffff);
|
||||
for(line = 0; line < MAX_STATUS_LINES; line++) {
|
||||
buf = g_status_ptrs[line];
|
||||
if(buf != 0) {
|
||||
len = strlen(buf);
|
||||
TextOut(localdc, 10, X_A2_WINDOW_HEIGHT +
|
||||
height*line + margin, buf, len);
|
||||
}
|
||||
}
|
||||
SetTextColor(localdc, oldtextcolor);
|
||||
SetBkColor(localdc, oldbkcolor);
|
||||
ReleaseDC(g_hwnd_main,localdc);
|
||||
*/
|
||||
}
|
||||
|
||||
int x_calc_ratio(float& ratiox,float& ratioy)
|
||||
{
|
||||
return 0; // not stretched
|
||||
}
|
||||
|
||||
|
255
kegs/AsmJS/asmjs_generic.cpp
Normal file
255
kegs/AsmJS/asmjs_generic.cpp
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
ActiveGS, Copyright 2004-2016 Olivier Goguel, https://github.com/ogoguel/ActiveGS
|
||||
Based on Kegs, Copyright 2004 Kent Dickey, https://kegs.sourceforge.net
|
||||
This code is covered by the GNU GPL licence
|
||||
*/
|
||||
|
||||
#include "../src/defc.h"
|
||||
#include "../src/video.h"
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <sdl.h>
|
||||
#else
|
||||
#include <sdl/sdl.h>
|
||||
|
||||
#endif
|
||||
|
||||
extern int g_lores_colors[];
|
||||
extern word32 g_palette_8to1624[256];
|
||||
extern word32 g_a2palette_8to1624[256];
|
||||
|
||||
void x_hide_pointer(int do_hide)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void x_full_screen(int do_full)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void x_show_color_array()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void x_recenter_hw_mouse()
|
||||
{
|
||||
}
|
||||
|
||||
void x_update_color(int col_num, int red, int green, int blue, word32 rgb)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
SDL_Surface* screen ;
|
||||
//SDL_Surface* offscreen ;
|
||||
|
||||
void x_video_init()
|
||||
{
|
||||
int lores_col;
|
||||
|
||||
printf("x_video_init\n");
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
screen = SDL_SetVideoMode(762, 504, 32, SDL_HWSURFACE);
|
||||
printf("BitsPerPixel: %d \n",screen->format->BitsPerPixel);
|
||||
printf("Rmask: %X \n",screen->format->Rmask);
|
||||
printf("Gmask: %X \n",screen->format->Gmask);
|
||||
printf("Bmask: %X \n",screen->format->Bmask);
|
||||
printf("Amask: %X \n",screen->format->Amask);
|
||||
|
||||
/*
|
||||
offscreen = SDL_CreateRGBSurface(SDL_HWSURFACE, screen->w, screen->h,
|
||||
screen->format->BitsPerPixel,
|
||||
screen->format->Rmask,
|
||||
screen->format->Gmask,
|
||||
screen->format->Bmask,
|
||||
screen->format->Amask
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
s_video.g_screen_depth = 32;
|
||||
s_video.g_screen_mdepth = 32;
|
||||
|
||||
s_video.g_red_mask = 0xff;
|
||||
s_video.g_green_mask = 0xff;
|
||||
s_video.g_blue_mask = 0xff;
|
||||
s_video.g_red_left_shift = 0;
|
||||
s_video.g_green_left_shift = 8;
|
||||
s_video.g_blue_left_shift = 16;
|
||||
s_video.g_red_right_shift = 0;
|
||||
s_video.g_green_right_shift = 0;
|
||||
s_video.g_blue_right_shift = 0;
|
||||
|
||||
video_get_kimages();
|
||||
|
||||
if(s_video.g_screen_depth != 8) {
|
||||
// Allocate g_mainwin_kimage
|
||||
video_get_kimage(&s_video.g_mainwin_kimage, 0, s_video.g_screen_depth, s_video.g_screen_mdepth);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 256; i++) {
|
||||
lores_col = g_lores_colors[i & 0xf];
|
||||
video_update_color_raw(i, lores_col);
|
||||
g_a2palette_8to1624[i] = g_palette_8to1624[i];
|
||||
}
|
||||
|
||||
init_kimage(&g_kimage_offscreen,0,s_video.g_screen_depth, s_video.g_screen_mdepth);
|
||||
|
||||
// init offscreen
|
||||
//memset(&g_kimage_offscreen,0,sizeof(g_kimage_offscreen));
|
||||
g_kimage_offscreen.width_req = X_A2_WINDOW_WIDTH;
|
||||
g_kimage_offscreen.width_act = X_A2_WINDOW_WIDTH;
|
||||
g_kimage_offscreen.height = X_A2_WINDOW_HEIGHT;
|
||||
//g_kimage_offscreen.depth = g_screen_depth;
|
||||
//g_kimage_offscreen.mdepth = g_screen_mdepth;
|
||||
x_get_kimage(&g_kimage_offscreen);
|
||||
|
||||
s_video.g_installed_full_superhires_colormap = 1;
|
||||
}
|
||||
|
||||
void x_get_kimage(Kimage *kimage_ptr)
|
||||
{
|
||||
byte *ptr;
|
||||
int width;
|
||||
int height;
|
||||
int depth, mdepth;
|
||||
int size;
|
||||
|
||||
width = kimage_ptr->width_req;
|
||||
height = kimage_ptr->height;
|
||||
depth = kimage_ptr->depth;
|
||||
mdepth = kimage_ptr->mdepth;
|
||||
|
||||
printf("x_get_kimage %dx%d\n",width,height);
|
||||
/*
|
||||
SDL_Surface* layer = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height,
|
||||
screen->format->BitsPerPixel,
|
||||
screen->format->Rmask,
|
||||
screen->format->Gmask,
|
||||
screen->format->Bmask,
|
||||
screen->format->Amask
|
||||
);
|
||||
|
||||
kimage_ptr->data_ptr = NULL; //layer->pixels;
|
||||
kimage_ptr->dev_handle = (void *)layer;
|
||||
*/
|
||||
|
||||
size = 0;
|
||||
if(depth == s_video.g_screen_depth)
|
||||
{
|
||||
|
||||
kimage_ptr->width_act = width ;
|
||||
size = height* kimage_ptr->width_act * mdepth >> 3;
|
||||
ptr = (byte *)malloc(size);
|
||||
|
||||
if(ptr == 0)
|
||||
{
|
||||
printf("malloc for data fail, mdepth:%d\n", mdepth);
|
||||
exit(2);
|
||||
}
|
||||
kimage_ptr->data_ptr = ptr;
|
||||
kimage_ptr->dev_handle = (void *)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
kimage_ptr->width_act = width ;
|
||||
size = height* kimage_ptr->width_act * mdepth >> 3 ;
|
||||
ptr = (byte *)malloc(size);
|
||||
|
||||
if(ptr == 0)
|
||||
{
|
||||
printf("malloc for data fail, mdepth:%d\n", mdepth);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
kimage_ptr->data_ptr = ptr;
|
||||
kimage_ptr->dev_handle = (void *)-1;
|
||||
}
|
||||
|
||||
|
||||
printf("kim: %p, dev:%p data: %p, size: %08x\n", kimage_ptr,kimage_ptr->dev_handle, kimage_ptr->data_ptr, size);
|
||||
|
||||
}
|
||||
|
||||
void x_video_shut()
|
||||
{
|
||||
}
|
||||
|
||||
void x_auto_repeat_on(int must)
|
||||
{
|
||||
}
|
||||
|
||||
void x_auto_repeat_off(int must)
|
||||
{
|
||||
}
|
||||
|
||||
void x_push_kimage(Kimage *kimage_ptr, int destx, int desty, int srcx, int srcy, int width, int height)
|
||||
{
|
||||
|
||||
SDL_LockSurface(screen);
|
||||
|
||||
int pixsize = kimage_ptr->mdepth>>3 ;
|
||||
int srcrow = kimage_ptr->width_act * pixsize;
|
||||
int dstrow = screen->pitch;;
|
||||
int byte2copy = width * pixsize ;
|
||||
|
||||
|
||||
// printf("x_push_kimage %d x %d (%d)\n",width,height,kimage_ptr->mdepth);
|
||||
|
||||
|
||||
|
||||
char* ptrdest = (char*)screen->pixels +dstrow*desty + destx*pixsize;
|
||||
// printf("writing to %X\n",ptrdest);
|
||||
char* srcdest = (char*)kimage_ptr->data_ptr + srcrow*srcy + srcx*pixsize;
|
||||
for(int i=0;i<height;i+=1)
|
||||
{
|
||||
memcpy(ptrdest,srcdest,byte2copy);
|
||||
ptrdest += dstrow;;
|
||||
srcdest += srcrow;
|
||||
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(screen);
|
||||
// SDL_Flip(screen);
|
||||
|
||||
g_video_offscreen_has_been_modified = 1;
|
||||
// SDL_BlitSurface(offscreen,NULL,screen,NULL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void asmjs_video_update()
|
||||
{
|
||||
if(g_video_offscreen_has_been_modified)
|
||||
{
|
||||
g_video_offscreen_has_been_modified = 0;
|
||||
SDL_Flip(screen);
|
||||
}
|
||||
}
|
||||
|
||||
void x_release_kimage(Kimage *kimage_ptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void x_refresh_video()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void x_update_physical_colormap()
|
||||
{
|
||||
}
|
||||
|
||||
void x_update_modifiers(word32 _mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user