gr-sim: add double-lores support

This commit is contained in:
Vince Weaver 2025-03-23 14:32:04 -04:00
parent 6e59a5fb10
commit 8596cc17f7
7 changed files with 153 additions and 0 deletions

24
utils/gr-sim/dgr/Makefile Normal file
View File

@ -0,0 +1,24 @@
CC = gcc
CFLAGS = -Wall -O2 -I.. -g
LFLAGS = -lm
SDL_LIBS= `sdl-config --libs`
SDL_INCLUDE= `sdl-config --cflags`
GR_SIM = ../gr-sim.a
all: dgr_view
###
dgr_view: dgr_view.o $(GR_SIM)
$(CC) -o dgr_view dgr_view.o $(GR_SIM) $(LFLAGS) $(SDL_LIBS)
dgr_view.o: dgr_view.c
$(CC) $(CFLAGS) -c dgr_view.c
###
clean:
rm -f *~ *.o dgr_view

BIN
utils/gr-sim/dgr/aha1.aux Normal file

Binary file not shown.

BIN
utils/gr-sim/dgr/aha1.main Normal file

Binary file not shown.

BIN
utils/gr-sim/dgr/aha1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

View File

@ -0,0 +1,61 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "gr-sim.h"
int main(int argc, char **argv) {
int ch,fd;
if (argc<2) {
fprintf(stderr,"Usage: dhgr_view FILENAME.AUX FILENAME.MAIN\n");
fprintf(stderr," where FILENAME AUX/MAIN are 8k AppleII DHIRES dumps\n\n");
}
grsim_init();
home();
soft_switch(SET_GR);
soft_switch(LORES);
soft_switch(FULLGR);
soft_switch_write(CLRAN3);
soft_switch_write(SET80_COL);
soft_switch_write(EIGHTY_COLON);
soft_switch(SET_PAGE2);
/* Load AUX RAM */
fd=open(argv[1],O_RDONLY);
if (fd<0) {
printf("Error opening!\n");
return -1;
}
read(fd,&ram[0x10400],1024);
close(fd);
soft_switch(SET_PAGE1);
/* load MAIN RAM */
fd=open(argv[2],O_RDONLY);
if (fd<0) {
printf("Error opening!\n");
return -1;
}
read(fd,&ram[0x00400],1024);
close(fd);
grsim_update();
while(1) {
ch=grsim_input();
if (ch) break;
usleep(100000);
}
return 0;
}

View File

@ -22,6 +22,12 @@
#define GR_X_SCALE 14
#define GR_Y_SCALE 8
/* 80x48 double low-res mode */
#define DGR_XSIZE 80
#define DGR_YSIZE 48
#define DGR_X_SCALE 7
#define DGR_Y_SCALE 8
/* 40 column only for now */
#define TEXT_XSIZE 40
#define TEXT_YSIZE 24
@ -466,6 +472,64 @@ void draw_text(unsigned int *out_pointer,int text_start, int text_end) {
}
static void draw_dlores(unsigned int *out_pointer,int gr_start, int gr_end) {
int i,j,yy,xx;
int gr_addr,gr_addr_hi;
int temp_col;
unsigned int *t_pointer;
t_pointer=out_pointer+(gr_start*80*DGR_X_SCALE*DGR_Y_SCALE);
/* do the top 40/48 if in graphics mode */
for(yy=gr_start;yy<gr_end;yy++) {
for(j=0;j<DGR_Y_SCALE;j++) {
gr_addr=gr_addr_lookup[yy/2];
gr_addr_hi=yy%2;
/* adjust for page */
/* FIXME */
if (text_page_1) {
gr_addr+=0x400;
}
for(xx=0;xx<DGR_XSIZE/2;xx++) {
/* even from aux */
if (gr_addr_hi) {
temp_col=(ram[gr_addr+0x10000]&0xf0)>>4;
}
else {
temp_col=ram[gr_addr+0x10000]&0x0f;
}
for(i=0;i<DGR_X_SCALE;i++) {
*t_pointer=dcolor[temp_col];
t_pointer++;
}
/* odd from main */
if (gr_addr_hi) {
temp_col=(ram[gr_addr]&0xf0)>>4;
}
else {
temp_col=ram[gr_addr]&0x0f;
}
for(i=0;i<DGR_X_SCALE;i++) {
*t_pointer=color[temp_col];
t_pointer++;
}
gr_addr++;
}
}
}
}
/* FIXME: this is simplistic and just draws ideal colors */
/* in theory we could do proper NTSC calculations */
@ -643,6 +707,9 @@ int grsim_update(void) {
if ((hires_on) && (an3_on) && (eightycol_on)) {
draw_dhires(t_pointer,0,192);
}
else if ((an3_on) && (eightycol_on)) {
draw_dlores(t_pointer,0,48);
}
else if (hires_on) {
draw_hires(t_pointer,0,192);
}

View File

@ -112,6 +112,7 @@ int plot(unsigned char xcoord, unsigned char ycoord);
#define HIRES 0xc057 // hires mode
#define DHIRES_ON 0xc05e // double-hires on
#define AN3 0xc05e // annunciator 3
#define CLRAN3 0xc05e // annunciator 3
#define DHIRES_OFF 0xc05f // double-hires off
#define DHIRES_RD 0xc07f // double-hires read