robhagemans / pcbasic

PC-BASIC - A free, cross-platform emulator for the GW-BASIC family of interpreters
http://www.pc-basic.org
Other
393 stars 48 forks source link

Changing the 8-pixel font by `POKE` works differently from GW-BASIC #198

Open robhagemans opened 2 years ago

robhagemans commented 2 years ago

PC-BASIC can change the 8-bit font in CGA mode, but the way this works is different from GW-BASIC.

Consider the code from PC-Magazine's PEEKs and POKES articles (12 Nov 1985 and 26 Nov 1985):

30 SCREEN 1,0:COLOR 1,1:KEY OFF:CLS
70 CLEAR,49152!
90 DEFINT I:I=0
100 DEF SEG=0
110 POKE 124,0
120 POKE 125,192
130 POKE 126,PEEK(1296)
140 POKE 127,PEEK(1297)
150 DEF SEG
160 POKE 49152!,132
170 POKE 49153!,136
180 POKE 49154!,158
190 POKE 49155!,162
200 POKE 49156!,70
210 POKE 49157!,130
220 POKE 49158!,14
230 POKE 49159!,0
240 LOCATE 12,20:PRINT CHR$(128)

This is expected to show a redefined glyph that resembles the vulgar fraction 1/3. However, PC-BASIC does not allow changing low-memory addresses 124--126, and instead needs the user to overwrite the original addresses where the font is stored:

30 SCREEN 1,0:COLOR 1,1:KEY OFF:CLS
100 DEF SEG=0
150 ADDR=PEEK(125)*256+PEEK(124)
155 DEF SEG=PEEK(127)*256+PEEK(126)
160 POKE ADDR  ,132
170 POKE ADDR+1,136
180 POKE ADDR+2,158
190 POKE ADDR+3,162
200 POKE ADDR+4,70
210 POKE ADDR+5,130
220 POKE ADDR+6,14
230 POKE ADDR+7,0
240 LOCATE 12,20:PRINT CHR$(128)

This in turn does not work on GW-BASIC on DOSBox. Note however that the original code does not work on DOSBox either and shows a glyph made up of random dots. It may well be that DOSBox's emulation does not allow setting these memory ranges.

Further investigation needed to see if the original font address can be overwritten in GW-BASIC (not on DOSBox) or if this is a ROM area instead.

robhagemans commented 2 years ago

Update: VirtualBox's CGA mode emulation seems broken entirely, but both bits of code work on a PC AT simulated on pcjs.org.