News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_norecess464

Faster TXT_OUTPUT (BB5A) routine

Started by norecess464, 15:38, 04 September 23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

norecess464

Hi,

I have a program of mine that prints text in both MODE 1 and MODE 2, and relies on the TXT_OUTPUT (&BB5A) firmware routine.
Sometimes, the screen requires to scroll vertically, as in BASIC when too much information gets printed to screen, etc.

I tried to optimize TXT_OUTPUT a little bit while keeping 464/6128 compatibility, and reached an interesting 2.8 faster time execution.
Putting here my findings. Maybe a similar effort existed in the past, I did not check. That was quite fun to implement!
Warning, it also comes with few restrictions (no management of PEN 2/3, reverse character mode, etc).

Sharing is caring!
 :-*

The info as found at the beginning of the attach Fast_TXT_OUTPUT.asm file. Compiles with RASM.
; Originally written by norecess464 in 2023
; Compiles with RASM by roudoudou
;
; This routine is 2.8 times faster than the original TXT_OUTPUT
; Compatible with all the CPC firmware versions
;
; It entirely relies on firmware's cursor position routine,
; and supports well the screen hardware scrolling / window management routines.
;
; The main acceleration is provided by outputting the "go right" character code (9)
; with the original TXT_OUTPUT, so all the firmware handling, character positionning,
; screen scrolling etc. gets correctly handled
; But instead of relying on TXT_OUTPUT's print-to-screen routine, we directly
; copy the character bitmap from the LOWER ROM. MODE2 is a direct copy,
; while MODE 1 relies on a table (512 bytes) to make a quick conversion to MODE 1.
;
; Notes:
; - TXT_GET_CURSOR KL_L_ROM_ENABLE SCR_CHAR_POSITION SCR_GET_MODE.. are not what makes
;  this routine "slow", it doesn't worth to try optimizing to hell those ones.
;  Plus, it would be risky to break 464/6128 compatibility
;
; It comes with few restrictions:
; - no support PEN 2 and PEN 3
; - no support for MODE 0
; - no support for reverse character mode, etc.

My personal website: https://norecess.cpcscene.net
My current project is Sonic GX, a remake of Sonic the Hedgehog for the awesome Amstrad GX-4000 game console!

McArti0

Other insertion point is BDD3 but realy BB5A is called earlier in FW.
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

Prodatron

Thanks, @NoRecess!

seems, that you can even save additional 4 NOPs/char in the Mode 2 routine by replacing every 2nd

ld a, d
 add a, b
ld d, a

with SET 3,D


GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Prodatron

MODE2PIXEL

inc l
    set 3,d
; D=#C8
MODE2PIXEL

inc l
inc l
    set 4,d

; D=#D8
MODE2PIXEL

dec l
    res 3,d
; D=#D0
MODE2PIXEL

    set 2,l
    set 5,d
; D=#F0
MODE2PIXEL

inc l
    set 3,d
; D=#F8
MODE2PIXEL

    res 1,l
    res 4,d
; D=#E8
MODE2PIXEL

dec l
    res 3,d
; D=#E0
MODE2PIXEL

This should save another 2 NOPs, as you don't need
LD B,8
anymore.
(not tested)

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Prodatron

Oh, and with the same method (using SET/RES for L as well) you can save 2 NOPs in the Mode1 routine, too :D
I know, nobody will recognize it, but it is always fun :)

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

norecess464

#5
Ahah yes, good catch, thank you! Updated source code attached.
My personal website: https://norecess.cpcscene.net
My current project is Sonic GX, a remake of Sonic the Hedgehog for the awesome Amstrad GX-4000 game console!

Powered by SMFPacks Menu Editor Mod