Page 2 of 4
Re: Let's calculate! - renewed arithmetic routines
Posted: Sun Jun 10, 2018 8:23 pm
by siggi
Maybe Pokemon could fix that in his ZxMore Master program? He seems to be busy at the moment, but meanwhile a "patch" for running your new ROMs at ZxMore would help? Changing some bytes in the beginning of the ROM should not be too complicated (man POKE
)
Siggi
Edit: I have sent a PM to Pokemon
Re: Let's calculate! - renewed arithmetic routines
Posted: Mon Jun 11, 2018 3:07 pm
by siggi
olofsen wrote: ↑Sun Jun 10, 2018 9:29 am
The LD HL,($400C) in the NMI routine is three bytes earlier, at $0071, so that there is no display.
If that is the only reason: maybe it would be sufficient to leave the "NMI-CONT" routine at its original place? That would not waste time, only some bytes space ...
Siggi
Re: Let's calculate! - renewed arithmetic routines
Posted: Mon Jun 11, 2018 5:54 pm
by olofsen
While the NMI routine is shorter and faster, NMI-CONT is (three bytes) longer and also slower. I guess it will be hard for the ZXmaster to check for the number of T states taken by the original or modified NMI-CONT...
Re: Let's calculate! - renewed arithmetic routines
Posted: Mon Jun 11, 2018 7:57 pm
by zsolt
Hi,
This is not so simple:
Code: Select all
; ------------------------------------
; THE 'NON MASKABLE INTERRUPT' ROUTINE
; ------------------------------------
;
; ( It takes 29 clock cycles while incrementing towards zero - it was 32TS).
;; NMI
L0066:
EX AF,AF' ; (4) switch in the NMI's copy of the
; accumulator.
INC A ; (4) increment.
;
; JP M,L006D (10) was removed for faster NMI-service: the user application gets +3TS/NMI
;
JR Z,L006C ; (12) forward to NMI-CONT
; when line count has incremented to zero.
;
;; NMI-RET (7!!!) else
;
EX AF,AF' ; (4) switch out the incremented line counter
; or test result $80
RET ; (10) return to User application for a while.
; ---
; This branch is taken when the 55 (or 31) lines have been drawn.
;; NMI-CONT (its address was L006F)
L006C:
EX AF,AF' ; (4) restore the main accumulator.
PUSH AF ; (11) * Save Main Registers
PUSH BC ; (11) **
PUSH DE ; (11) ***
PUSH HL ; (11) ****
; the next set-up procedure is only really applicable when the top set of
; blank lines have been generated.
LD HL,($400C) ; (16) fetch start of Display File from D_FILE
; points to the HALT at beginning.
SET 7,H ; (8) point to upper 32K 'echo display file'
HALT ; (1) HALT synchronizes with NMI.
; Used with special hardware connected to the
; Z80 HALT and WAIT lines to take 1 clock cycle.
OUT ($FD),A ; (11) Stop the NMI generator.
JP IX_to_PC ; (10) Delay because of the removed 'JP M,...'
IX_to_PC
JP (IX) ; (8) forward to L0281 (after top) or L028F
In the original code (after the 'HALT') the NMI service requires 4+4+10(!)+7+4+10=39 T states, because A'=1 (positive, nonzero).
In case of the patched routine: 4+4+7+4+10=29 T states. So the 'JP IX_to_PC' is necessary for the correct displaying.
Is it possible to see the "master"-code?
Zsolt
Re: Let's calculate! - renewed arithmetic routines
Posted: Tue Jun 12, 2018 11:45 am
by siggi
Hi Zsolt
zsolt wrote: ↑Mon Jun 11, 2018 7:57 pm
Is it possible to see the "master"-code?
Pokemon has not published this code, so currently the answer is NO. But I will ask Pokemon (but he is very busy at the moment).
My
assumption is, that the master code "catches" the NMI and executes it in its own ROM (to check for task switch conditions and for double-shift-keys).
After that is done it probably jumps back to the application ROM to execute the application NMI routine (if necessary). The well known address in the ZX81 ROM is NMI-CONT at L006F.
So maybe moving NMI-CONT from $006C to $006F would solve that problem?
Maybe the display timing would be a little bit distorted (caused by the different runtime in SG81G, which the master software does not expect), but maybe the display would be back again?
Code: Select all
;; NMI
L0066:
EX AF,AF' ; (4) switch in the NMI's copy of the
; accumulator.
INC A ; (4) increment.
;
; JP M,L006D (10) was removed for faster NMI-service: the user application gets +3TS/NMI
;
JR Z,L006C ; (12) forward to NMI-CONT
; when line count has incremented to zero.
;
;; NMI-RET (7!!!) else
;
EX AF,AF' ; (4) switch out the incremented line counter
; or test result $80
RET ; (10) return to User application for a while.
; ---
; This branch is taken when the 55 (or 31) lines have been drawn.
Add here some NOPs (which will NOT be executed!) to move NMI-CONT down of $006F ..
Code: Select all
;; NMI-CONT (its address was L006F)
L006C:
EX AF,AF' ; (4) restore the main accumulator.
PUSH AF ; (11) * Save Main Registers
PUSH BC ; (11) **
PUSH DE ; (11) ***
PUSH HL ; (11) ****
; the next set-up procedure is only really applicable when the top set of
; blank lines have been generated.
LD HL,($400C) ; (16) fetch start of Display File from D_FILE
; points to the HALT at beginning.
SET 7,H ; (8) point to upper 32K 'echo display file'
HALT ; (1) HALT synchronizes with NMI.
; Used with special hardware connected to the
; Z80 HALT and WAIT lines to take 1 clock cycle.
OUT ($FD),A ; (11) Stop the NMI generator.
JP IX_to_PC ; (10) Delay because of the removed 'JP M,...'
IX_to_PC
JP (IX) ; (8) forward to L0281 (after top) or L028F
Currently I do not have setup an environment to compile (and modify for own tests) your ROM ....
Siggi
Re: Let's calculate! - renewed arithmetic routines
Posted: Tue Jun 12, 2018 3:58 pm
by zsolt
Re: Let's calculate! - renewed arithmetic routines
Posted: Tue Jun 12, 2018 7:13 pm
by siggi
Hi Zsolt,
now the display is working
But it is a little bit disturbed: the first 3 pixel lines are shifted right:
Thus there seems to be a small timing difference.
Siggi
Re: Let's calculate! - renewed arithmetic routines
Posted: Tue Jun 12, 2018 7:27 pm
by zsolt
Hi Siggi,
How it looks using
this sgmore?
Thx,
Zsolt
Re: Let's calculate! - renewed arithmetic routines
Posted: Tue Jun 12, 2018 7:42 pm
by siggi
Using the SGMORE.ROM the display is OK (no shifted pixels).
I think I should use this rom for further math tests, until Pokemon has time to help.
Siggi
Re: Let's calculate! - renewed arithmetic routines
Posted: Wed Jun 13, 2018 11:24 pm
by olofsen
The attached version is Zsolt's latest, with a first try to make the BASIC LOAD and SAVE commands work using USB, even in compatibility mode. In the filename, only A-Z are allowed, and .P is added automatically.