News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_fgbrain

Split raster on CPC PLUS - possible ASIC bug ?

Started by fgbrain, 14:17, 05 March 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fgbrain

Hi!!

I am experimenting with split rasters on WinAPE for plus machines.
Came up with this piece of code (while trying to make the thinnest split-raster bars possible on plus)...:



org &8000
run $
nolist
di

ld bc,&bc02:out(c),c:ld a,50:inc b:out(c),a  ;top-left of monitor!
ld bc,&bc01:out(c),c:ld a,48:inc b:out(c),a  ;top-left of monitor!

ld b,&bc
ld hl,sequence
ld e,17
.seq
ld a,(hl)
out (c),a
inc hl
dec e
jr nz,seq
ei

;; install a interrupt handler

di
im 1
ld hl,&c9fb
ld (&0038),hl
ei

.main_loop

ld b,&f5
.ml1
in a,(c)
rra
jr nc,ml1

;; wait for interrupt
halt

;; wait for interrupt
halt

;; wait for interrupt
halt

;; wait for interrupt
halt
halt
;; delay
defs 25 ;exact top-left spot!!

;; page-in asic registers to &4000-&7fff
ld bc,&7fb8                    ;; [3]
out (c),c                    ;; [4]

ld de,&6400                    ;; colour 0

ld hx,30
di:ld(spback+1),sp:ld sp,rasterarray

.rl
;; read colour from table (a word at a time)
;; write colour to ASIC colour palette (a word at a time)
pop hl:ld(&6400),hl ;3+5=8
pop hl:ld(&6400),hl ;3+5=8
pop hl:ld(&6400),hl ;3+5=8
pop hl:ld(&6400),hl ;3+5=8
pop hl:ld(&6400),hl ;3+5=8
pop hl:ld(&6400),hl ;3+5=8
ds 64-48-5

dec hx                        ;; [2]
jp nz,rl                    ;; [3]

spback ld sp,0:ei
;; page-out asic registers
ld bc,&7fa0
out (c),c

jp main_loop

;; - there is two bytes per colour.
align 256
.rasterarray

dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
dw &fff,&111,&fff,&111,&fff,&111,&fff,&111
.end_rasterarray

;; this is the sequence to unlock the ASIC extra features
.sequence
defb &ff,&00,&ff,&77,&b3,&51,&a8,&d4,&62,&39,&9c,&46,&2b,&15,&8a,&cd,&ee


list
end



This code should produce bars of one colour(&FFF) on screen, but 3 colors in each bar are displayed instead !!! :o


I cant tell if its an emulator bug, because I havent tried it on actual machine yet..
Perhaps ASIC bug then??


Any advice is welcomed!!

_____

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.

andycadley

16-bit writes aren't an atomic operation on the Z80, so you can't change both bytes of a Plus palette entry in one go. So if the current colour is &111 and HL contains $FFF when you do LD (&6400),HL then the following sequence occurs:

The Low Byte of HL is written to &6400, the palette entry now contains &1FF - a purple colour
The High Byte of HL is written to &6400, the palette entry now contains &FFF - a white

Similarly the change in the other direction goes

The Low Byte of HL is written to &6400, the palette entry now contains &F11 - a green colour
The High Byte of HL is written to &6401, the palette entry now contains &111 - almost black.

Hopefully that is enough for you to see what is happening in your code. And yes, this does make split rasters awkward on the Plus unless you keep either the G or RB component constant.

arnoldemu

@andycadley is correct, you are seeing the colour transition as each byte is written.
Not the emulator and I don't know if it's a "bug" or not in the asic.

It is our "ham" mode  ;D
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

fgbrain

Thanks for your info..

So every 8 ms, the ASIC changes color 3 times right?
Is possible to make a raster scroller? We d run out of registers I believe this way..
_____

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.

arnoldemu

Write 1 byte only (red and blue).

Then you can do something like this

e.g.

ld hl,&6400 ;; or 6401 I need to check
ld b,&0f ;; pens
ld c,&f0
ld d,&ff
ld e,&88

ld (hl),b
ld (hl),c
ld (hl),d
ld (hl),e



You can then have you rasters defined as ld (hl) bytes and scroll it.

e.g.

ld hl,&6400
ld (hl),&0f
ld (hl),&f0
ld (hl),&ff
ld (hl),&88


a little bit slower, here you need to poke your raster colours into the opcodes.

Your limited to red and blue channels only but no problem with changes and the raster changes are small.

I did check and using old OUT method does an instant change, but it's same length as cpc and same colours as cpc so no advantage here.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

roudoudou

Quote from: fgbrain on 19:32, 05 March 16
Thanks for your info..

So every 8 ms, the ASIC changes color 3 times right?
Is possible to make a raster scroller? We d run out of registers I believe this way..


Hi, i'v just wrote an article about split-raster with some examples (google translate from french to english)
https://translate.google.fr/translate?hl=fr&sl=fr&tl=en&u=http%3A%2F%2Fwww.roudoudou.com%2Fcode%2Fsplitraster%2F


for the CPC+ case and the 16bits write problem, it's better to split when the ink is not displayed. In other words, split with two inks!

Axelay

Quote from: fgbrain on 19:32, 05 March 16
Is possible to make a raster scroller? We d run out of registers I believe this way..


I did do a little test in WinAPE on this a long time ago, not tested on real hardware as I dont have a Plus.  It's just a hack of one of arnoldemus split raster examples though, and just does exactly what arnoldemu described above.






org &8000
nolist
run &8000


; unlock plus features
di
ld b,&bc
ld hl,sequence
ld e,17
.seq
ld a,(hl)
out (c),a
inc hl
dec e
jr nz,seq
ei




;;----------------------------------------
;; initialise interrupts
;;
;; setup a dummy interrupt handler


di      ;; disable interrupts
im 1     ;; interrupt mode 1
ld hl,&c9fb    ;; C9:FB corresponds to the instructions EI:RET
ld (&0038),hl   ;; write instructions to interrupt vector
ei      ;; enable interrupts


;;----------------------------------------
;; the main loop which displays the raster


.main_loop
;;----------------------------------------
;; wait for the start of the vsync


ld b,&f5
.ml1
in a,(c)
rra
jr nc,ml1


halt


halt


; add new one


ld hl,noplist
ld a,(RastScr)
ld e,a
ld d,0
add hl,de
halt
di
jp (hl)
;;------------------------------------
;; delay so that the first colour change is invisible (it occurs
;; during the horizontal flyback)


.noplist
defs 18 ;30-2


;;------------------------------------
;; select the pen index to change the colour of
;ld bc,&7f00
;out (c),c


;ld c,&54


;; page-in asic registers to &4000-&7fff
ld bc,&7fb8 ;; [3]
out (c),c ;; [4]


ld hl,&6400 ;; colour 0 red & blue
ld c,0
inc hl
ld (hl),c
dec hl
;;------------------------------------
;; change the colours
             
ld de,AlertColourList2   ;; table of colours for all split rasters


ld b,24                    ;; number of complete scanlines that the split rasters
                          ;; cover


.rl2


defs 64-50-1-3-4+2
ld a,(de)
inc de
.line1
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
dec b                     ;; [1]
jp nz,rl2                 ;; [3]




ld b,24
;jp rl3+3 ;+5
jp rl3+5
.rl3
;ld c,(hl)
;inc hl
;defs 4
defs 64-50-1-3-4+2
ld a,(de)
inc de
.line2
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
dec b
jp nz,rl3


ld b,24
jp rl4+5
.rl4
defs 64-50-1-3-4+2
ld a,(de)
inc de
.line3
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
dec b
jp nz,rl4


ld b,24
jp rl5+5
.rl5
defs 64-50-1-3-4+2
ld a,(de)
inc de
.line4
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
dec b
jp nz,rl5


ld b,24
jp rl6+5
.rl6
defs 64-50-1-3-4+2
ld a,(de)
inc de
.line5
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
ld (hl),c
dec b
jp nz,rl6






;;------------------------------------
;; reset the pen back to black


;ld bc,&7f54
;out (c),c


ld (hl),c


;; page-out asic registers
ld bc,&7fa0
out (c),c


ei




;;------------------------------------
;; and loop again to refresh the raster


;
;jp main_loop
;


ld a,(RastScr)
inc a
cp a,2
jr nz,skipreset
xor a
.skipreset
ld (RastScr),a
jp nz,main_loop
ld a,(textoffset)
inc a
cp a,65 ;33
jr nz,skipreset2
xor a
.skipreset2
ld (textoffset),a
ld hl,textlist
ld e,a
ld d,0
add hl,de


ld bc,&7f00
out (c),c


;ld bc,&7f5c
;out (c),c


ld de,line5
push de
ld de,line4
push de
ld de,line3
push de
ld de,line2
push de
ld de,line1
push de
ld bc,&5ff
.modloop
pop de
ld a,24
.modlpin
ldi
;inc de
dec a
jr nz,modlpin
ld de,88-24
add hl,de
djnz modloop


;ld bc,&7f54
;out (c),c


jp main_loop


;;------------------------------------


.RastScr
defb 0
.textoffset
defb 0


.textlist
defb &71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&77,&77,&77,&77,&71,&71,&71,&77,&77,&71,&71,&71,&71,&71,&71,&77,&77,&77,&77
defb &77,&77,&71,&71,&77,&77,&77,&77,&77,&71,&71,&71,&77,&77,&77,&77,&77,&77,&71,&71,&77,&77,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71
defb &71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&77,&71,&71,&77,&71,&71,&71,&77,&77,&71,&71,&71,&71,&71,&71,&77,&77,&71,&71
defb &71,&71,&71,&71,&77,&77,&71,&71,&77,&77,&71,&71,&71,&71,&77,&77,&71,&71,&71,&71,&77,&77,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71
defb &71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&77,&77,&77,&77,&77,&77,&71,&71,&77,&77,&71,&71,&71,&71,&71,&71,&77,&77,&77,&77
defb &71,&71,&71,&71,&77,&77,&77,&77,&77,&71,&71,&71,&71,&71,&77,&77,&71,&71,&71,&71,&77,&77,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71
defb &71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&77,&77,&71,&71,&77,&77,&71,&71,&77,&77,&71,&71,&71,&71,&71,&71,&77,&77,&71,&71
defb &71,&71,&71,&71,&77,&77,&71,&71,&77,&77,&71,&71,&71,&71,&77,&77,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71
defb &71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&77,&77,&71,&71,&77,&77,&71,&71,&77,&77,&77,&77,&77,&77,&71,&71,&77,&77,&77,&77
defb &77,&77,&71,&71,&77,&77,&71,&71,&77,&77,&71,&71,&71,&71,&77,&77,&71,&71,&71,&71,&77,&77,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71,&71




.AlertColourList2
    defb &33,&33,&33,&44,&44,&44
    defb &55,&55,&55,&66,&66,&66,&77,&77,&77,&88,&88,&88
    defb &99,&99,&99,&aa,&aa,&aa,&bb,&bb,&bb,&cc,&cc,&cc
    defb &dd,&dd,&dd,&ee,&ee,&ee,&ff,&ff,&ff,&fe,&fe,&fe
    defb &fd,&fd,&fd,&fc,&fc,&fc,&fb,&fb,&fb,&fa,&fa,&fa
    defb &f9,&f9,&f9,&f8,&f8,&f8,&f7,&f7,&f7,&f6,&f6,&f6
    defb &f5,&f5,&f5,&f4,&f4,&f4,&f3,&f3,&f3,&f2,&f2,&f2
    defb &f1,&f1,&f1,&f0,&f0,&f0,&e0,&e0,&e0,&d0,&d0,&d0
    defb &c0,&c0,&c0,&b0,&b0,&b0,&a0,&a0,&a0,&90,&90,&90
    defb &80,&80,&80,&70,&70,&70,&60,&60,&60,&50,&50,&50
    defb &40,&40,&40,&30,&30,&30
;;----------------------------------------------------------
;; this is the sequence to unlock the ASIC extra features
.sequence
defb &ff,&00,&ff,&77,&b3,&51,&a8,&d4,&62,&39,&9c,&46,&2b,&15,&8a,&cd,&ee

Powered by SMFPacks Menu Editor Mod