FPGA replacment for the ZX8301 ULA and more
Re: FPGA replacment for the ZX8301 ULA and more
Hi,
I'll add joystick support to the game, no problem.
I'll make it easy to identify the board, maybe I'll reserve a couple of bytes somewhere to contain a identifying value.
Most of the time I'm waiting for pcbs or parts to arrive.
I'll add joystick support to the game, no problem.
I'll make it easy to identify the board, maybe I'll reserve a couple of bytes somewhere to contain a identifying value.
Most of the time I'm waiting for pcbs or parts to arrive.
Leon
Projects: https://hackaday.io/projects/hacker/357657
Projects: https://hackaday.io/projects/hacker/357657
Re: FPGA replacment for the ZX8301 ULA and more
Might be worth agreeing something with the SMSQ/E authors - this page's Machine Type article describes how some add-ons are identified already, as bits within the system variables.
https://dilwyn.qlforum.co.uk/docs/articles/index.html
https://dilwyn.qlforum.co.uk/docs/articles/index.html
--
All things QL - https://dilwyn.qlforum.co.uk/index.html
All things QL - https://dilwyn.qlforum.co.uk/index.html
Re: FPGA replacment for the ZX8301 ULA and more
By the way, in the last version I have included a 512K flash Ic that is used to choose booting from different roms.
Leon
Projects: https://hackaday.io/projects/hacker/357657
Projects: https://hackaday.io/projects/hacker/357657
Re: FPGA replacment for the ZX8301 ULA and more
It says "a largely undocumented system variable has been added". But not mentioend where was it added. In SMSQ/E? In some extension that has to be loaded?dilwyn wrote: ↑Thu Oct 19, 2023 5:02 pm Might be worth agreeing something with the SMSQ/E authors - this page's Machine Type article describes how some add-ons are identified already, as bits within the system variables.
https://dilwyn.qlforum.co.uk/docs/articles/index.html
Re: FPGA replacment for the ZX8301 ULA and more
I think it's the same system variables that the MACHINE and PROCESSOR extensions in SBASIC use to store machine type and processor type. Offsets $A1 (processor type) and $A7 (machine type). As that article is quite old, it's quite possible extra information has since been added.
I *think* the system variables concerned started being used when Miracle made their products like Super Gold Card and people wanted to be able to test in software what platform programs were running on. Over time it developed and SBASIC extensions like MACHINE and PROCESSOR became available to make it easier without faffing about in the system variables.
This is the article which appeared in QL Today at some point, over a decade ago. Unsure if ever updated for later systems like Q68. I've tried putting it in a Quote tag, not sure how well the formatting will work.
I *think* the system variables concerned started being used when Miracle made their products like Super Gold Card and people wanted to be able to test in software what platform programs were running on. Over time it developed and SBASIC extensions like MACHINE and PROCESSOR became available to make it easier without faffing about in the system variables.
This is the article which appeared in QL Today at some point, over a decade ago. Unsure if ever updated for later systems like Q68. I've tried putting it in a Quote tag, not sure how well the formatting will work.
WHICH MACHINE AM I RUNNING ON?
(updated 24/01/13 for SMSQmulator Machine Type)
An interesting problem which faces QL programmers now is testing to see which of the multitude of QL-Compatibles the program is actually running on. To facilitate this, a largely undocumented system variable has been added and SBASIC for example has inbuilt BASIC keywords to test and return values associated with this. In general, software would of course run on any machine type, but it is possible that assembler programmers may wish to identify the machine or processor type to build time-critical loops, or to take advantage of facilities available on more recent machines by introducing two routines, one to take advantage of the new facilites to speed up or otherwise improve the program, the other a more general set of code to work on all machines.
The new system variable sys_ptyp at offset $A1 (decimal 161) contains a byte holding values which identify the type of processor and if any floating point unit is available.
The top 4 bits (high nibble, or bits 4-7) identify the processor type:
HEX DECIMAL PROCESSOR TYPE
0x 0+ 68000 or 68008
1x 16+ 68010
2x 32+ 68020
3x 48+ 68030
4x 64+ 68040
6x 96+ 68060
The bottom 4 bits (lower nibble, or bits 0-3) contains information about any floating point unit available. It takes the form:
HEX DECIMAL FPU DETAILS
0 0 No FPU available
1 1 Internal MMU
2 2 68851 MMU
4 4 internal FPU
8 8 68881 or 68882 FPU
The new system variable at $A7 (decimal 167) contains a byte holding information about the machine type. Bit 0 indicates if a Hermes or Blitter chip is installed (depending on machine), bits 1 to 4 indicate the machine or emulator type, while bits 5 to 7 indicate the display type as shown in Marcel's list below.
sys_mtyp equ $00a7 byte Machine type / display type
HEX DECIMAL
sys.mtyp equ $1e 30 machine ID in these bits
; bit 0
sys.blit equ +1 Blitter fitted (Atari)
sys.herm equ +1 Hermes fitted (QL)
;bits 1 to 4...
sys.mst equ $00 0 ordinary ST or QL
sys.mstr equ $02 2 Mega ST or ST with RTC
sys.msta equ $04 4 Stacy
sys.mste equ $06 6 ordinary STE
sys.mmste equ $08 8 Mega STE
sys.mgold equ $0a 10 Gold Card
sys.msgld equ $0c 12 Super Gold Card
sys.mfal equ $10 16 Falcon
sys.mq40 equ $11 17 Q40
sys.msms equ $14 20 SMSQmulator
sys.mtt equ $18 24 TT 030
sys.mqxl equ $1c 28 QXL
sys.mqpc equ $1e 30 QPC
sys.mqlay equ $1f 31 QLay emulator
;bits 5 to 7...
sys.mfut equ %00000000 (dec. +0) Standard QL or Futura type of display
sys.mmon equ %00100000 (dec. +32) Monochrome monitor
sys.mext equ %01000000 (dec. +64) Atari Extended 4 Emulator
sys.mvme equ %10000000 (dec. +128) Atari QVME emulator
sys.mqlc equ %11000000 (dec. +192) QL mode LCD
sys.mvga equ %11000000 (dec. +192) VGA
sys.maur equ %10100000 (dec. +160) Aurora
To locate these system variables from assembler, ensure you call sms.info (trap #0, d0=$00, system variables address returned in a0) then add the offsets mentioned to the base address and analyse the values at those locations. From BASIC, use any of the commonly available toolkit extensions to locate the system variables, for example, on Minerva or SMSQE yoy can use the VER$(-2) function to return the base address of the system variables.
EXAMPLES
This little BASIC program will list the information it can extract, somewhat along the lines of the equivalent SBASIC extensions MACHINE, PROCESSOR and DISP_TYPE in SMSQ/E.
100 sv = 163840 : REMark fixed location on original QL
110 t$ = VER$ : REMark check version of BASIC
120 IF t$ = 'JSL1' OR t$ = 'HBA' THEN
130 REMark Minerva or SBASIC, supports ver$(-2)
140 sv = VER$(-2)
150 END IF
160 processor_type = PEEK(sv+161)
170 REMark separate processor and FPU type
180 fpu_type = processor_type && 15
190 processor_type = processor_type DIV 16
200 machine_type = PEEK(sv+167)
210 REMark mask out machine_type into the machine and display components
220 display_type = machine_type DIV 32
230 machine_type = machine_type && 31
240 PRINT"Processor Type:";
250 SELect ON processor_type
260 =0 : PRINT"68000 or 68008"
270 =1 : PRINT"68010 (possibly QPC)"
280 =2 : PRINT"68020"
290 =3 : PRINT"68030"
300 =4 : PRINT"68040"
400 =5 : PRINT"Someone must have made a 68050 unit!"
410 =6 : PRINT"68060"
420 =REMAINDER:PRINT"Unknown"
430 END SELect
440 IF fpu_type > 0 THEN PRINT"FPU available"
450 PRINT"Display type:";
460 SELect ON display_type
470 =0 : PRINT"QL style display"
480 =1 : PRINT"Monochrome display"
490 =2 : PRINT"Atari Extended Mode 4"
500 =4 : PRINT"Atari QVME display"
510 =5 : PRINT"Aurora display"
520 =6 : PRINT"QL Mode LCD"
530 =7 : PRINT"VGA displays"
540 =REMAINDER : PRINT"Unknown"
550 END SELect
560 PRINT"Machine Type:";
570 SELect ON machine_type
580 =0,1 : PRINT"Unknown, probably a standard QL"
580 =2,3 : PRINT"Mega ST or ST with RTC"
590 =4,5 : PRINT"Stacy"
600 =6,7 : PRINT"Atari STE"
610 =8,9 : PRINT"Atari Mega STE"
620 =10,11: PRINT"Gold Card"
630 =12,13: PRINT"Super Gold Card"
640 =16,17: PRINT"Falcon"
650 =17,18: PRINT"Q40"
655 =20,21: PRINT"SMSQmulator"
660 =24,25: PRINT"Atari TT 030"
670 =28,29: PRINT"QXL"
680 =30,31: PRINT"QPC"
690 =REMAINDER : PRINT"Unknown"
700 END SELect
710 IF machine_type && 1 : PRINT"Hermes or Blitter installed"
Or if you prefer a set of functions to return the hardware details, try these:
1000 DEFine FuNction S_V
1010 LOCal t$
1020 t$ = VER$
1030 IF t$ = 'JSL1' OR t$ = 'HBA' THEN
1040 RETurn VER$(-2)
1050 ELSE
1060 RETurn 163840 : REMark QDOS QL fixed location
1070 END IF
1080 END DEFine S_V
1090 :
1100 DEFine Function MACHINE_TYPE
1110 LOCal mt
1120 mt = PEEK(S_V+167)
1130 RETurn (mt && 31)
1140 END DEFine MACHINE_TYPE
1150 :
1160 DEFine FuNction DISPLAY_TYPE
1170 LOCal mt
1180 mt = PEEK(S_V+167) && (128+64+32)
1190 RETurn (mt DIV 32)
1200 END DEFine DISPLAY_TYPE
1210 :
1220 DEFine FuNction PROCESSOR_TYPE
1230 LOCal pt
1240 pt = PEEK(S_V+161)
1250 RETurn (pt DIV 16)
1260 END DEFine PROCESSOR_TYPE
1270 :
1280 DEFine FuNction DISPLAY_TYPE
1290 LOCal pt
1300 pt = PEEK(S_V+161)
1310 RETurn (pt && 15)
1320 END DEFine DISPLAY_TYPE
1330 :
1340 DEFine FuNction HERMES_OR_BLITTER
1350 LOCal mt
1360 mt = PEEK(S_V+167)
1370 RETurn (mt && 1)
1380 END DEFine HERMES_OR_BLITTER
Last edited by dilwyn on Thu Oct 19, 2023 9:42 pm, edited 1 time in total.
Reason: typo
Reason: typo
--
All things QL - https://dilwyn.qlforum.co.uk/index.html
All things QL - https://dilwyn.qlforum.co.uk/index.html
Re: FPGA replacment for the ZX8301 ULA and more
But where are these extensions located? Probably not in QDOS. In SMSQ/E? In something else that has to be loaded?
That's exactly what I had read. It does not give a hint where that system variable comes from.
Re: FPGA replacment for the ZX8301 ULA and more
Sorry, I'm not sure I understand? There are extensions in SBASIC (i.e. SMSQ/E) - the MACHINE and PROCESSOR extensions in SBASIC. But the information can only be read from QDOS/SuperBASIC on later systems such as Gold Card/Super Gold Card etc by PEEKing around the system variables as in the examples. There is no equivalent extension extension to do this in SuperBASIC AFAIK, only by writing short routines like in the article.
I have no idea where it all came from - maybe people like Tony Tebby / Jochen Merz / Miracle Systems / Marcel felt the need to implement something like this as new systems came along just to flag up and remember what type of display and processor a system had? I didn't even know about it until just before that article in QL Today, where Marcel helped with the information, but he was a little reluctant at the time - I think he may have been reluctant to encourage people to start playing around in the system variables, maybe?
Certainly if we were to try to extend this to add values for lliont 's 8301 replacement, Q68 etc it'd need co-operation from Wolfgang and the OS maintainers to ensure it's all added "officially" to SMSQ/E, to prevent future clashes. Of course, lliont may have his own idea on how to identify this device just by providing something within the device itself which is unique to that device, without affecting these system variables.
There is a limited reference to these values in the QDOS Reference Guide's list of system variables. I'll check that book to see if there's any additional information compared to what is in the article I copied here. The values are also listed in my big SBASIC / SMSQE manual under MACHINE and PROCESSOR. The values in the two system variables are the same as those returned by MACHINE and PROCESSOR extensions.
QDOS Reference Guide:
I have no idea where it all came from - maybe people like Tony Tebby / Jochen Merz / Miracle Systems / Marcel felt the need to implement something like this as new systems came along just to flag up and remember what type of display and processor a system had? I didn't even know about it until just before that article in QL Today, where Marcel helped with the information, but he was a little reluctant at the time - I think he may have been reluctant to encourage people to start playing around in the system variables, maybe?
Certainly if we were to try to extend this to add values for lliont 's 8301 replacement, Q68 etc it'd need co-operation from Wolfgang and the OS maintainers to ensure it's all added "officially" to SMSQ/E, to prevent future clashes. Of course, lliont may have his own idea on how to identify this device just by providing something within the device itself which is unique to that device, without affecting these system variables.
There is a limited reference to these values in the QDOS Reference Guide's list of system variables. I'll check that book to see if there's any additional information compared to what is in the article I copied here. The values are also listed in my big SBASIC / SMSQE manual under MACHINE and PROCESSOR. The values in the two system variables are the same as those returned by MACHINE and PROCESSOR extensions.
QDOS Reference Guide:
Code: Select all
; system variable offset $A1
sys_ptyp $00A1 Byte PRoCeSsor type $00=68000/8, $30=68030 etc. [SMSQ]
sys.mtyp $1E Machine ID bits
sys.immu $01 Internal MMU
sys.851m $02 68851 MMU
sys.ifpu $04 Internal FPU
sys.88xf $08 68881 68882 FPU
; system variable offset $A7
sys_mtyp $00A7 Byte Machine TYPe / emulator type [SMS,ST]
sys.mtyp $1E Machine ID bits
sys.mblt +1 Blitter fitted [SMSQ, ST]
sys.herm +1 Hermes fitted [SMSQ, QL]
sys.mst $00 Ordinary ST
sys.mstr $02 Mega ST or ST with RTC
sys.msta $04 Stacy
sys.mste $06 Ordinary STE
sys.mmste $08 Mega STE
sys.mgold $0A Gold card
sys.msgld $0C SuperGold card
sys.mfal $10 Falcon
sys.mq40 $11 Q40/Q60
sys.java $14 SMSQmulator
sys.mtt $18 TT
sys.mqxl $1C QXL
sys.qpc $1E QPC
sys.mdsp %11100000 Display type mask
sys.mfut %00000000 Futura emulator or none
sys.mmon %00100000 Monochrome monitor
sys.mext %01000000 Extended 4 Emulator
sys.mvme %10000000 QVME emulator or QL mode LCD
sys.mvga %11000000 VGA
sys.maur %10000000 Aurora
--
All things QL - https://dilwyn.qlforum.co.uk/index.html
All things QL - https://dilwyn.qlforum.co.uk/index.html
Re: FPGA replacment for the ZX8301 ULA and more
Let me ask the other way. Do QDOS and Minerva also implement the system variable, or does it depend on SMSQ/E?
If it depends on SMSQ/E, it is not a general method for all who use the ZX8301 replacement.
Re: FPGA replacment for the ZX8301 ULA and more
Hardware dependent. BBQL - no. Only add-ons from Gold Card onward which put patches in QDOS, i.e. nothing 68008 as far as I know. Some emulators, but I don't have a full list. AFAIK it isn't at operating system level in QDOS, just set relevant bits in those system variables.
Anyone here know any more than I do on this subject?
--
All things QL - https://dilwyn.qlforum.co.uk/index.html
All things QL - https://dilwyn.qlforum.co.uk/index.html
Re: FPGA replacment for the ZX8301 ULA and more
sys_mtyp and sys_ptyp (for processor and machine) are included in the "normal" range of QDOS system variables ($a1, $a7) and unused on original QDOS (they're only filled if you run SMSQ/E). If you read the variable on a black box running QDOS, it will simply return its initialization value 0, which means "68000/08, 'standard' box" (Actually, "standard ST", as it was first introduced with ST-QL).
A driver could be made to populate those two variables with specific values when it detects it's not running under SMSQ/E. You could maybe use the "blitter" bit that was reserved for the ST-QL.
A driver could be made to populate those two variables with specific values when it detects it's not running under SMSQ/E. You could maybe use the "blitter" bit that was reserved for the ST-QL.
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO