Commit c534fc47 authored by Sergio Costas's avatar Sergio Costas

Moved screen low level process to its own class

parent fe308117
......@@ -7,8 +7,8 @@ CPPFLAGS += `pkg-config --cflags sdl libpulse-simple alsa` -O2 -D D_SOUND_PULSE
LDFLAGS += `pkg-config --libs sdl libpulse-simple alsa`
fbzx: cargador.o characters.o computer.o emulator.o menus.o microdrive.o sound.o spk_ay.o tape.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o
$(LN) -o fbzx cargador.o characters.o computer.o emulator.o menus.o microdrive.o sound.o spk_ay.o tape.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o $(LDFLAGS)
fbzx: cargador.o computer.o emulator.o llscreen.o menus.o microdrive.o sound.o spk_ay.o tape.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o
$(LN) -o fbzx cargador.o computer.o emulator.o llscreen.o menus.o microdrive.o sound.o spk_ay.o tape.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o $(LDFLAGS)
Z80free.o: z80free/Z80free.c z80free/Z80free.h
$(CC) -o Z80free.o z80free/Z80free.c
......@@ -34,30 +34,30 @@ Z80free_codesDDCB.o: z80free/Z80free_codesDDCB.c z80free/Z80free.h
Z80free_codesFDCB.o: z80free/Z80free_codesFDCB.c z80free/Z80free.h
$(CC) -o Z80free_codesFDCB.o z80free/Z80free_codesFDCB.c
cargador.o: cargador.cpp emulator.hh z80free/Z80free.h computer.hh tape.hh cargador.hh
cargador.o: cargador.cpp emulator.hh z80free/Z80free.h computer.hh llscreen.hh tape.hh cargador.hh
$(CPP) $(CPPFLAGS) -o cargador.o cargador.cpp
characters.o: characters.cpp emulator.hh z80free/Z80free.h computer.hh tape.hh characters.hh
$(CPP) $(CPPFLAGS) -o characters.o characters.cpp
computer.o: computer.cpp tape.hh emulator.hh z80free/Z80free.h computer.hh spk_ay.hh sound.hh microdrive.hh menus.hh characters.hh
computer.o: computer.cpp tape.hh emulator.hh z80free/Z80free.h computer.hh llscreen.hh spk_ay.hh sound.hh microdrive.hh menus.hh
$(CPP) $(CPPFLAGS) -o computer.o computer.cpp
emulator.o: emulator.cpp sound.hh microdrive.hh z80free/Z80free.h menus.hh computer.hh tape.hh emulator.hh characters.hh cargador.hh
emulator.o: emulator.cpp sound.hh microdrive.hh z80free/Z80free.h menus.hh llscreen.hh emulator.hh computer.hh tape.hh cargador.hh
$(CPP) $(CPPFLAGS) -o emulator.o emulator.cpp
menus.o: menus.cpp menus.hh tape.hh emulator.hh z80free/Z80free.h computer.hh characters.hh cargador.hh
llscreen.o: llscreen.cpp llscreen.hh emulator.hh z80free/Z80free.h computer.hh tape.hh
$(CPP) $(CPPFLAGS) -o llscreen.o llscreen.cpp
menus.o: menus.cpp llscreen.hh emulator.hh z80free/Z80free.h computer.hh tape.hh menus.hh cargador.hh
$(CPP) $(CPPFLAGS) -o menus.o menus.cpp
microdrive.o: microdrive.cpp emulator.hh z80free/Z80free.h computer.hh tape.hh microdrive.hh
microdrive.o: microdrive.cpp emulator.hh z80free/Z80free.h computer.hh llscreen.hh tape.hh microdrive.hh
$(CPP) $(CPPFLAGS) -o microdrive.o microdrive.cpp
sound.o: sound.cpp sound.hh emulator.hh z80free/Z80free.h computer.hh tape.hh
sound.o: sound.cpp sound.hh emulator.hh z80free/Z80free.h computer.hh llscreen.hh tape.hh
$(CPP) $(CPPFLAGS) -o sound.o sound.cpp
spk_ay.o: spk_ay.cpp sound.hh emulator.hh z80free/Z80free.h computer.hh tape.hh
spk_ay.o: spk_ay.cpp sound.hh emulator.hh z80free/Z80free.h computer.hh llscreen.hh tape.hh
$(CPP) $(CPPFLAGS) -o spk_ay.o spk_ay.cpp
tape.o: tape.cpp z80free/Z80free.h tape.hh emulator.hh computer.hh
tape.o: tape.cpp z80free/Z80free.h tape.hh emulator.hh computer.hh llscreen.hh
$(CPP) $(CPPFLAGS) -o tape.o tape.cpp
This diff is collapsed.
/*
* Copyright 2003-2009 (C) Raster Software Vigo (Sergio Costas)
* This file is part of FBZX
*
* FBZX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* FBZX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
extern unsigned char characters[96][32];
void printchar(unsigned char *,unsigned char,int,int,unsigned char,unsigned char,int);
void print_string(unsigned char *,char*,int,int,unsigned char,unsigned char,int);
This diff is collapsed.
......@@ -25,6 +25,7 @@
#include "tape.hh"
#include "z80free/Z80free.h"
#include "llscreen.hh"
// #define MUT
......@@ -39,7 +40,7 @@ struct computer {
unsigned int temporal_io;
// screen private global variables
SDL_Surface *screen;
//SDL_Surface *screen;
unsigned char *screenbuffer;
unsigned int screen_width;
unsigned int translate[6144],translate2[6144];
......@@ -56,7 +57,6 @@ struct computer {
int currline,currpix;
int tstados_counter; // counts tstates leaved to the next call
int resx,resy,bpp; // screen resolutions
int init_line; // cuantity to add to the base address to start to paint
int next_line; // cuantity to add when we reach the end of line to go to next line
int next_scanline; // cuantity to add to pass to the next scanline
......@@ -213,8 +213,5 @@ void emulate(int);
void ResetComputer();
byte bus_empty();
void set_memory_pointers();
void paint_one_pixel(unsigned char *colour,unsigned char *address);
void computer_set_palete();
void set_palete_entry(unsigned char entry, byte Value);
#endif
......@@ -26,12 +26,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
#include "cargador.hh"
#include "characters.hh"
#include "computer.hh"
#include "llscreen.hh"
#include "menus.hh"
#include "microdrive.hh"
#include "sound.hh"
......@@ -40,27 +38,16 @@ char debug_var=1;
Z80FREE procesador;
struct computer ordenador;
SDL_Surface *screen;
//SDL_Surface *screen;
char salir,sound_aborted;
unsigned char *sound[NUM_SNDBUF];
char path_snaps[2049];
char path_taps[2049];
char path_mdrs[2049];
unsigned int colors[80];
unsigned int jump_frames,curr_frames;
unsigned int jump_frames, curr_frames;
char *filenames[5];
void SDL_Fullscreen_Switch()
{
Uint32 flags = screen->flags;
if ( flags & SDL_FULLSCREEN )
flags &= ~SDL_FULLSCREEN;
else
flags |= SDL_FULLSCREEN;
screen = SDL_SetVideoMode(screen->w, screen->h, screen->format->BitsPerPixel,flags);
}
FILE *myfopen(char *filename,char *mode) {
char tmp[4096];
......@@ -89,7 +76,7 @@ char *load_a_rom(char **filenames) {
int offset=0;
FILE *fichero;
int size;
for(pointer=filenames;*pointer!=NULL;pointer++) {
fichero=myfopen(*pointer,"r");
if(fichero==NULL) {
......@@ -195,64 +182,9 @@ void load_rom(char type) {
fclose(fichero);
}
void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hwsurface) {
int retorno,bucle,bucle2,valores,ret2;
unsigned char value;
//if (sound_type!=3)
retorno=SDL_Init(SDL_INIT_VIDEO);
/*else
retorno=SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);*/
if(retorno!=0) {
printf("Can't initialize SDL library. Exiting\n");
exit(1);
}
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
ordenador.use_js=0;
printf("Can't initialize JoyStick subsystem\n");
} else {
printf("JoyStick subsystem initialized\n");
ordenador.use_js=1;
if(SDL_NumJoysticks()>0){
// Open joystick
for (bucle=0;bucle<SDL_NumJoysticks();bucle++) {
if (NULL==SDL_JoystickOpen(bucle)) {
printf("Can't open joystick %d\n",bucle);
}
}
}
}
// screen initialization
valores=SDL_HWPALETTE|SDL_ANYFORMAT;
if (fullscreen==1)
valores|=SDL_FULLSCREEN;
if (dblbuffer==1)
valores|=SDL_DOUBLEBUF;
if (hwsurface==1)
valores|=SDL_HWSURFACE;
else
valores|=SDL_SWSURFACE;
screen=SDL_SetVideoMode(resx,resy,depth,valores);
if(screen==NULL) {
printf("Can't assign SDL Surface. Exiting\n");
exit(1);
}
ordenador.bpp=screen->format->BytesPerPixel;
printf("Bytes per pixel: %d\n",ordenador.bpp);
if(SDL_MUSTLOCK(screen)) {
ordenador.mustlock=1;
SDL_LockSurface(screen);
} else
ordenador.mustlock=0;
void init_sound() {
printf("Locking screen\n");
int bucle,bucle2,ret2;
// sound initialization
......@@ -288,7 +220,7 @@ void end_system() {
sound_close();
if(ordenador.mustlock)
SDL_UnlockSurface(screen);
SDL_UnlockSurface(llscreen->screen);
if(ordenador.tap_file!=NULL)
fclose(ordenador.tap_file);
......@@ -466,7 +398,11 @@ void load_config(struct computer *object) {
int main(int argc,char *argv[]) {
int bucle,tstados,argumento,fullscreen,dblbuffer,hwsurface,length;
int bucle,tstados,argumento,length;
bool fullscreen = false;
bool dblbuffer = false;
bool hwsurface = false;
bool text_mini = false;
char gamefile[4096];
word PC=0;
......@@ -474,13 +410,9 @@ int main(int argc,char *argv[]) {
sound_type=SOUND_AUTOMATIC;
gamefile[0]=0;
ordenador.zaurus_mini=0;
ordenador.text_mini=0;
ordenador.ulaplus=0;
ordenador.ulaplus_reg=0;
fullscreen=0;
dblbuffer=0;
hwsurface=0;
argumento=0;
jump_frames=0;
curr_frames=0;
......@@ -560,16 +492,16 @@ int main(int argc,char *argv[]) {
argumento++;
} else if (0==strcmp(argv[argumento],"-micro")) {
ordenador.zaurus_mini=3;
ordenador.text_mini=1;
text_mini = true;
argumento++;
}else if(0==strcmp(argv[argumento],"-fs")) {
fullscreen=1;
fullscreen = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-hw")) {
hwsurface=1;
hwsurface = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-db")) {
dblbuffer=1;
dblbuffer = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-ds")) {
ordenador.dblscan=1;
......@@ -597,28 +529,29 @@ int main(int argc,char *argv[]) {
atexit(end_system);
switch(ordenador.zaurus_mini) {
case 0:
init_screen(640,480,0,0,dblbuffer,hwsurface);
llscreen = new LLScreen(640,480,0,0,dblbuffer,hwsurface,text_mini);
break;
case 1:
case 2:
init_screen(480,640,0,0,dblbuffer,hwsurface);
llscreen = new LLScreen(480,640,0,0,dblbuffer,hwsurface,text_mini);
break;
case 3:
init_screen(320,240,0,0,dblbuffer,hwsurface);
llscreen = new LLScreen(320,240,0,0,dblbuffer,hwsurface,text_mini);
break;
}
init_sound();
printf("Modo: %d\n",ordenador.mode128k);
register_screen(screen);
register_screen(llscreen->screen);
printf("Screen registered\n");
printf("Modo: %d\n",ordenador.mode128k);
if(fullscreen) {
SDL_Fullscreen_Switch();
llscreen->fullscreen_switch();
}
SDL_WM_SetCaption("FBZX","");
ordenador.interr=0;
ordenador.screenbuffer=(unsigned char *)ordenador.screen->pixels;
ordenador.screen_width=ordenador.screen->w;
ordenador.screenbuffer=(unsigned char *)llscreen->screen->pixels;
ordenador.screen_width=llscreen->screen->w;
// assign initial values for PATH variables
......@@ -669,7 +602,7 @@ int main(int argc,char *argv[]) {
sleep(1);
printf("Reset screen\n");
clean_screen();
llscreen->clean_screen();
if (sound_aborted==1) {
strcpy(ordenador.osd_text,"Running without sound (read the FAQ)");
......@@ -684,7 +617,7 @@ int main(int argc,char *argv[]) {
sprintf(ordenador.osd_text,"Press F1 for help");
ordenador.osd_time=200;
printf("BPP: %d\n",ordenador.bpp);
printf("BPP: %d\n",llscreen->bpp);
while(salir) {
do {
......
......@@ -27,7 +27,7 @@
extern char debug_var;
extern SDL_Surface *screen;
//extern SDL_Surface *screen;
extern Z80FREE procesador;
extern struct computer ordenador;
extern unsigned char *sound[NUM_SNDBUF];
......@@ -37,7 +37,6 @@ extern char path_mdrs[2049];
extern unsigned int colors[80];
extern unsigned int jump_frames,curr_frames;
void SDL_Fullscreen_Switch(void);
void load_rom(char);
void load_main_game(char *nombre);
FILE *myfopen(char *filename,char *mode);
......
This diff is collapsed.
......@@ -17,6 +17,8 @@
*
*/
#include "llscreen.hh"
struct fichero {
char nombre[256]; // filename (for files and directories)
char nombrepath[2049]; // filename with path
......@@ -26,7 +28,6 @@ struct fichero {
enum LOAD_FILE_TYPES {FILETYPE_Z80, FILETYPE_TAP_TZX, FILETYPE_MDR, FILETYPE_SCR};
void clean_screen();
void help_menu();
void load_z80file();
char *select_file(char *,enum LOAD_FILE_TYPES);
......
/*
* Copyright 2003-2015 (C) Raster Software Vigo (Sergio Costas)
* This file is part of FBZX
*
* FBZX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* FBZX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* tape.cpp
*
......
/*
* Copyright 2003-2015 (C) Raster Software Vigo (Sergio Costas)
* This file is part of FBZX
*
* FBZX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* FBZX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* tape.hpp
*
......@@ -14,6 +33,19 @@
#ifndef SRC_TAPE_HPP_
#define SRC_TAPE_HPP_
/*
class TapeSignal {
class Tape *tape_object;
~TapeSignal();
public:
virtual void callback_pause(bool pause) = 0;
void register_tape_object(class Tape *tape);
};
typedef void (TapeSignal::*signal_pause) (bool);
*/
enum FastLoadReturn {FASTLOAD_OK, FASTLOAD_NO_BLOCK, FASTLOAD_NO_TAPE, FASTLOAD_NO_FLAG, FASTLOAD_END_TAPE};
class Tape {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment