Author Topic: 32-character-width screen mode  (Read 4983 times)

0 Members and 1 Guest are viewing this topic.

Offline cpcitor

  • The user previously known as FindYWay
  • CPC6128
  • ****
  • Posts: 224
  • Country: fr
  • My heart still runs on traditional CPC.
    • My code for the CPC.
  • Liked: 105
Re: Beware of slow instructions
« Reply #40 on: 16:17, 05 November 13 »
Close, it's actually 312 * 64 = 19968 microseconds per frame.

Does this mean that a CPC frame rate is not exactly 50Hz but 1000000/19968, about 50.08 Hz ?
Had a CPC since 1985, currently software dev professional, including embedded systems.

I made the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC.

Offline Executioner

  • Supporter
  • 6128 Plus
  • *
  • Posts: 783
  • Country: au
  • WinAPE Developer
    • WinAPE
  • Liked: 385
Re: Beware of slow instructions
« Reply #41 on: 00:20, 08 November 13 »
Does this mean that a CPC frame rate is not exactly 50Hz but 1000000/19968, about 50.08 Hz ?

Yes, that is correct.

Offline ralferoo

  • Supporter
  • 6128 Plus
  • *
  • Posts: 966
  • Country: gb
  • Liked: 577
Re: 32-character-width screen mode
« Reply #42 on: 13:49, 09 November 13 »
BTW... There are also some unexpected timing like for LD BC,(NNNN) and LD IX,(NNNN). They need the same amount of time, but one would expect that the instruction using IX is 1 ys slower. But here it's not.
The timing on these instructions is totally as one would expect. There's not even a hint of the unexpected here.

LD HL,(xxxx) and LD (HL),xxxx were on the original 8080, so have normal opcodes (22 and 2A).
These always take 5us due to the memory accesses - IF, addrL, addrH, dataL, dataH.

LD rr,(xxxx) and LD (xxxx),rr are Z80 additional instructions and so are assigned codes in the ED space. There is a duplicated HL version here, but nobody uses it.
These always take 6us due to the memory accesses - IFprefix, IF, addrL, addrH, dataL, dataH.

LD Ir,(xxxx) and LD (xxxx),Ir are Z80 additional instructions but implemented with the IX/IY override bytes (DD or FD) but otherwise use the HL form. These ALWAYS take 1us longer than the equivalent HL form.
These always take 6us due to the memory accesses - IFoverride, IF, addrL, addrH, dataL, dataH.

Offline fgbrain

  • CPC6128
  • ****
  • Posts: 184
  • Country: gr
    • index.php?action=treasury
    • Chaos CPC Homepage
  • Liked: 79
Re: 32-character-width screen mode
« Reply #43 on: 11:00, 17 November 15 »

back to our initial subject..

a 32 X 32 char.  (64 x 256 bytes) screen can have this optimized way to calculate screen addresses, instead of this difficult and  slow equation which is

PROBLEM:
How to calculate in asm this equation
Code: [Select]
ADR=&C000+(Y\8)*64+(Y MOD 8)*&800+X
where X is 0-63 and Y is 0-255


SOLUTION
1. we create a 512 bytes (256 pixels in y) containing each next line in Y, say at &A400  (&C000,&C800,&D000,.....).  WARNING:  each address is not stored normally but like this:
    &C000 :   &00 poked at &A400   and &C0 poked at &A500  (+256 bytes),
    &C800 :   &00 poked at &A401   and &C8 poked at &A501  (+256 bytes), etc etc...
This is vital for speed purposes (8bit number madness).

2. now we can use this easy routine:


Code: [Select]
HL H=X and L=Y coordinates where X is 0-63 and Y is 0-255
LD A,H:LD H,&A4:ADD A,(HL):INC H:LD H,(HL):LD L,A
HL = screen address


« Last Edit: 20:54, 21 November 15 by fgbrain »
_____

6128 (UK keyboard, Crtc type 0/2), 6128+ (UK keyboard), 3.5" and 5.25" drives, Reset switch and Digiblaster (selfmade), Inicron Romram box, Bryce Megaflash, SVideo & PS/2 mouse, , Magnum Lightgun, X-MEM, X4 Board, C4CPC, Multiface2 X4, RTC X4 and Gotek USB Floppy emulator.

Offline rk last

  • CPC664
  • ***
  • Posts: 55
  • Country: 00
  • Liked: 40
Re: 32-character-width screen mode
« Reply #44 on: 02:21, 13 August 16 »
When you work with a reduced display how do you retune it to allow a vaild LOCATE.  As I recall, there is a formula that executes a cursor xpos=1, ypos=1 to return to the top left hand corner or anywhere else correctly on screen.

maRK

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.327
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 614
Re: 32-character-width screen mode
« Reply #45 on: 06:44, 13 August 16 »

When you work with a reduced display how do you retune it to allow a vaild LOCATE.  As I recall, there is a formula that executes a cursor xpos=1, ypos=1 to return to the top left hand corner or anywhere else correctly on screen.


If it's in MODE 0 I do:


x=x*32 - where x is 0..19, but that's for 20-character-width, so: x=x*20 will give you 32.


LOCATE is purely text only, so TAG..TAGOFF & MOVE can be used to position the text.


And for y I use y=398-(y*16) - where y is 0..24.


But you're talking about the Spectrum mode, which is 32 character width in mode 1.
« Last Edit: 06:47, 13 August 16 by AMSDOS »