Add quinn bits!
This commit is contained in:
parent
2d9b24f07c
commit
64a5496557
51
doomgeneric/Makefile.quinn
Normal file
51
doomgeneric/Makefile.quinn
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# $Id:$
|
||||||
|
#
|
||||||
|
# $Log:$
|
||||||
|
#
|
||||||
|
|
||||||
|
ifeq ($(V),1)
|
||||||
|
VB=''
|
||||||
|
else
|
||||||
|
VB=@
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
CC=i686-quinn-gcc # gcc or g++
|
||||||
|
CFLAGS+=-O3
|
||||||
|
#LDFLAGS+=$(SOSO_ROOT)/lib/crt1.o $(SOSO_ROOT)/lib/crti.o $(SOSO_ROOT)/lib/crtn.o
|
||||||
|
CFLAGS+=-Wall -D_DEFAULT_SOURCE # -DUSEASM
|
||||||
|
LIBS+= -lquinn -lfreetype -lpng -lz -lm
|
||||||
|
|
||||||
|
# subdirectory for objects
|
||||||
|
OBJDIR=build
|
||||||
|
OUTPUT=fbdoom
|
||||||
|
|
||||||
|
SRC_DOOM = i_main.o dummy.o am_map.o doomdef.o doomstat.o dstrings.o d_event.o d_items.o d_iwad.o d_loop.o d_main.o d_mode.o d_net.o f_finale.o f_wipe.o g_game.o hu_lib.o hu_stuff.o info.o i_cdmus.o i_endoom.o i_joystick.o i_scale.o i_sound.o i_system.o i_timer.o memio.o m_argv.o m_bbox.o m_cheat.o m_config.o m_controls.o m_fixed.o m_menu.o m_misc.o m_random.o p_ceilng.o p_doors.o p_enemy.o p_floor.o p_inter.o p_lights.o p_map.o p_maputl.o p_mobj.o p_plats.o p_pspr.o p_saveg.o p_setup.o p_sight.o p_spec.o p_switch.o p_telept.o p_tick.o p_user.o r_bsp.o r_data.o r_draw.o r_main.o r_plane.o r_segs.o r_sky.o r_things.o sha1.o sounds.o statdump.o st_lib.o st_stuff.o s_sound.o tables.o v_video.o wi_stuff.o w_checksum.o w_file.o w_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_quinn.o
|
||||||
|
OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM))
|
||||||
|
|
||||||
|
all: $(OUTPUT)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(OBJDIR)
|
||||||
|
rm -f $(OUTPUT)
|
||||||
|
rm -f $(OUTPUT).gdb
|
||||||
|
rm -f $(OUTPUT).map
|
||||||
|
|
||||||
|
$(OUTPUT): $(OBJS)
|
||||||
|
@echo [Linking $@]
|
||||||
|
i686-quinn-gcc -v $(LDFLAGS) $(OBJS) -o $(OUTPUT).exe $(LIBS)
|
||||||
|
|
||||||
|
$(OBJS): | $(OBJDIR)
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir -p $(OBJDIR)
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.c
|
||||||
|
@echo [Compiling $<]
|
||||||
|
$(VB)$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
print:
|
||||||
|
@echo OBJS: $(OBJS)
|
||||||
|
|
156
doomgeneric/doomgeneric_quinn.c
Normal file
156
doomgeneric/doomgeneric_quinn.c
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
#include "quinn.h"
|
||||||
|
#include "doomgeneric.h"
|
||||||
|
#include "doomkeys.h"
|
||||||
|
|
||||||
|
#define KEYQUEUE_SIZE 16
|
||||||
|
|
||||||
|
static unsigned short s_KeyQueue[KEYQUEUE_SIZE];
|
||||||
|
static unsigned int s_KeyQueueWriteIndex = 0;
|
||||||
|
static unsigned int s_KeyQueueReadIndex = 0;
|
||||||
|
|
||||||
|
static int window_handle = 0;
|
||||||
|
static char *surface;
|
||||||
|
|
||||||
|
static unsigned int start_ticks;
|
||||||
|
|
||||||
|
void exit_callback(int wh) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_exit() {
|
||||||
|
quinn_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned char convertToDoomKey(unsigned char scancode)
|
||||||
|
{
|
||||||
|
unsigned char key = 0;
|
||||||
|
|
||||||
|
switch (scancode)
|
||||||
|
{
|
||||||
|
case 0x1C:
|
||||||
|
key = KEY_ENTER;
|
||||||
|
break;
|
||||||
|
case 0x01:
|
||||||
|
key = KEY_ESCAPE;
|
||||||
|
break;
|
||||||
|
case 0x4B:
|
||||||
|
key = KEY_LEFTARROW;
|
||||||
|
break;
|
||||||
|
case 0x4D:
|
||||||
|
key = KEY_RIGHTARROW;
|
||||||
|
break;
|
||||||
|
case 0x48:
|
||||||
|
key = KEY_UPARROW;
|
||||||
|
break;
|
||||||
|
case 0x50:
|
||||||
|
key = KEY_DOWNARROW;
|
||||||
|
break;
|
||||||
|
case 0x1D:
|
||||||
|
key = KEY_FIRE;
|
||||||
|
break;
|
||||||
|
case 0x39:
|
||||||
|
key = KEY_USE;
|
||||||
|
break;
|
||||||
|
case 0x36:
|
||||||
|
key = KEY_RSHIFT;
|
||||||
|
break;
|
||||||
|
case 0x15:
|
||||||
|
key = 'y';
|
||||||
|
break;
|
||||||
|
case 0x31:
|
||||||
|
key = 'n';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uninput_cb(char c) {
|
||||||
|
unsigned char key = convertToDoomKey((unsigned char)c);
|
||||||
|
|
||||||
|
unsigned short keyData = (0 << 8) | key;
|
||||||
|
|
||||||
|
s_KeyQueue[s_KeyQueueWriteIndex] = keyData;
|
||||||
|
s_KeyQueueWriteIndex++;
|
||||||
|
s_KeyQueueWriteIndex %= KEYQUEUE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void input_cb(char c) {
|
||||||
|
unsigned char key = convertToDoomKey((unsigned char)c);
|
||||||
|
|
||||||
|
unsigned short keyData = (1 << 8) | key;
|
||||||
|
|
||||||
|
s_KeyQueue[s_KeyQueueWriteIndex] = keyData;
|
||||||
|
s_KeyQueueWriteIndex++;
|
||||||
|
s_KeyQueueWriteIndex %= KEYQUEUE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_Init() {
|
||||||
|
struct window_req_t wr;
|
||||||
|
struct widget_t *w;
|
||||||
|
__asm__ volatile ("int $0x30" : "=a" (start_ticks) : "0" (46));
|
||||||
|
|
||||||
|
// atexit(do_exit);
|
||||||
|
|
||||||
|
wr.x = 30;
|
||||||
|
wr.y = 30;
|
||||||
|
strcpy(wr.name, "DOOM");
|
||||||
|
wr.width = DOOMGENERIC_RESX;
|
||||||
|
wr.height = DOOMGENERIC_RESY;
|
||||||
|
wr.flags = 0;
|
||||||
|
wr.icon = NULL;
|
||||||
|
|
||||||
|
window_handle = quinn_req_window(&wr, exit_callback);
|
||||||
|
|
||||||
|
w = quinn_add_surface(window_handle, 0, 0, DOOMGENERIC_RESX, DOOMGENERIC_RESY, NULL, input_cb, uninput_cb);
|
||||||
|
surface = quinn_surface_get_surface(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_DrawFrame() {
|
||||||
|
quinn_render_no_alpha(window_handle, surface, DG_ScreenBuffer, DOOMGENERIC_RESX, DOOMGENERIC_RESY, 0, 0, DOOMGENERIC_RESX, DOOMGENERIC_RESY);
|
||||||
|
quinn_process();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_SleepMs(uint32_t ms) {
|
||||||
|
unsigned int ticks;
|
||||||
|
unsigned int now = 0;
|
||||||
|
__asm__ volatile ("int $0x30" : "=a" (ticks) : "0" (46));
|
||||||
|
|
||||||
|
while (ticks + (ms * 10) > now) {
|
||||||
|
quinn_yield();
|
||||||
|
__asm__ volatile ("int $0x30" : "=a" (now) : "0" (46));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t DG_GetTicksMs() {
|
||||||
|
unsigned int ticks;
|
||||||
|
__asm__ volatile ("int $0x30" : "=a" (ticks) : "0" (46));
|
||||||
|
return (ticks - start_ticks) * 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DG_GetKey(int *pressed, unsigned char *key) {
|
||||||
|
if (s_KeyQueueReadIndex == s_KeyQueueWriteIndex)
|
||||||
|
{
|
||||||
|
//key queue is empty
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned short keyData = s_KeyQueue[s_KeyQueueReadIndex];
|
||||||
|
s_KeyQueueReadIndex++;
|
||||||
|
s_KeyQueueReadIndex %= KEYQUEUE_SIZE;
|
||||||
|
|
||||||
|
*pressed = keyData >> 8;
|
||||||
|
*key = keyData & 0xFF;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_SetWindowTitle(const char *title) {
|
||||||
|
quinn_set_win_caption(window_handle, title);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user