Author Topic: ghouls'n goblins gx4000  (Read 9858 times)

0 Members and 1 Guest are viewing this topic.

Offline fano

  • Supporter
  • 6128 Plus
  • *
  • Posts: 802
  • Country: fr
  • Easter Egg Programmer
    • Easter Egg
  • Liked: 241
Re: ghouls'n goblins gx4000
« Reply #70 on: 15:21, 29 February 16 »
PRI is not only for visible area. It is based on char line counter (VC) and raster line counter (RC) in CRTC. VC=0,RC=0 is normally start of visible area.
Sorry , i misformuled the question as i see (consider?imagine?) the line 0 as the one where the hsync occurs.So my question (as it was not really a question but an assertion) , is is possible to cause PRI interrupt on/before the first line that generate pixels from screen memory ? but i think your post contains the reply , more , you came with another solution i didn't think thx ;)
« Last Edit: 15:23, 29 February 16 by fano »
"NOP" is the perfect program : short , fast and (known) bug free

Follow Easter Egg products on Facebook !

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 665
  • Liked: 269
Re: ghouls'n goblins gx4000
« Reply #71 on: 15:29, 29 February 16 »
One nice thing about using the DMA lists is that you can easily define unusual spacings of interrupts.

Also, by making the list slightly too short or long, you can make the positioning move up or down the display automatically. Which might make for some nice demo raster effects.

Offline Ast

  • 6128 Plus
  • ******
  • Posts: 780
  • Country: fr
    • Amstrad cpc Website of Ast/iMPACT
  • Liked: 451
Re: ghouls'n goblins gx4000
« Reply #72 on: 15:33, 29 February 16 »
One nice thing about using the DMA lists is that you can easily define unusual spacings of interrupts.

Also, by making the list slightly too short or long, you can make the positioning move up or down the display automatically. Which might make for some nice demo raster effects.
I don't understand how you do... Please give us an example coz i'm a little bit curious about that.
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

Amstrad Plus :: Découverte de la gamme Old et Plus des Cpc d'Amstrad.
All friends are welcomed !

Offline arnoldemu

  • 6128 Plus
  • ******
  • Posts: 4.932
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 1879
Re: ghouls'n goblins gx4000
« Reply #73 on: 15:35, 29 February 16 »
Sorry , i misformuled the question as i see (consider?imagine?) the line 0 as the one where the hsync occurs.So my question (as it was not really a question but an assertion) , is is possible to cause PRI interrupt on/before the first line that generate pixels from screen memory ? but i think your post contains the reply , more , you came with another solution i didn't think thx ;)
If PRI=1, then interrupt happens at the hsync on line 1. So result is effectively line 2.

If you want to have a PRI interrupt happen on line 0, do it on the final line of the display ;)

But, normal display without split has 312 lines. So we can't get that close.

Use traditional split and now we can get close :)

For SPLT it is different, it does wrap. If you set SPLT so that it wraps you can change line 1 (not line 0 because you can't make SPLT ever happen on this line, MA is taken from R12/R13 and not SPLT address).
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 665
  • Liked: 269
Re: ghouls'n goblins gx4000
« Reply #74 on: 15:39, 29 February 16 »
I don't understand how you do... Please give us an example coz i'm a little bit curious about that.
I'll try and knock up a sample later. Basically, the idea is you write a self maintaining DMA list that is, for example, 311 lines long. Each time it repeats, therefore, interrupts will occur 1 scanline earlier than the previous frame (since there are 312 lines). Change colours on the dma interrupt and it appears to move "up" the screen.

Offline Ast

  • 6128 Plus
  • ******
  • Posts: 780
  • Country: fr
    • Amstrad cpc Website of Ast/iMPACT
  • Liked: 451
Re: ghouls'n goblins gx4000
« Reply #75 on: 15:54, 29 February 16 »
So, i'm waiting for your example... I never use that way, but why not ?
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

Amstrad Plus :: Découverte de la gamme Old et Plus des Cpc d'Amstrad.
All friends are welcomed !

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 13.961
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 2299
Re: ghouls'n goblins gx4000
« Reply #76 on: 16:07, 29 February 16 »
I actually wish the hero sprite was changed to something better... loved the game, even on the CPC, but I always hated that ugly mess!

Offline Executioner

  • Supporter
  • 6128 Plus
  • *
  • Posts: 790
  • Country: au
  • WinAPE Developer
    • WinAPE
  • Liked: 374
Re: ghouls'n goblins gx4000
« Reply #77 on: 16:23, 29 February 16 »
If you're using an overscan screen there's only about 32 scan lines between the VSYNC interrupt and the top of the screen. If you previously set PRI to 0, set up the CRTC correctly at this point, you can have R9=0 (1 scan line per char), Adjust the Vertical Total (R4) to include the number of scan lines you wish before the top split (should be approximately R7 plus 32), set your screen address (R12 and R13) to use data from just about any contiguous block of memory so long as it doesn't cross an #800 boundary. You can also pre-set your Split Screen scan-line and address, and make sure sprites are hidden during the top section (mag 0). You can then set up PRI to happen after N scan lines, at which point you change R9 to 7 and enable all the sprites you need. If you use the ASIC split screen you'll have to add N * 8 to the Y position for all sprites.

Making sure you don't get part of your sprites convering your top score section is the hardest task since using either method it's difficult as the ASIC doesn't clip them to the split-screen and the CRTC split will restart the scan line counter (VCC * 8 + VLC). It's not possible to change the magnification of every sprite during the horizontal retrace period of a single scan line, so I'd probably recommend adding an extra scan line and set Horizontal displayed to 0 for that scan line.

One of the things I like to do is place some static timed code in sections where you have a little time to waste, such as displaying score characters, eg. render the whole score and high-score every frame rather than adding an extra interrupt handler for close rasters. You may be able to get a few characters drawn between raster palette changes for example.

The calculations to ensure you have 312 scan lines can be difficult when you mix different R9 values. Using the example 4 character (32 scan line) from Toto with R9 = 0 (these calculations are only approximate and would need to be tested).

Since your top screen uses 33 characters to display 33 scan lines, rather than 4 characters to display 32 scan lines your value for R7 should be adjusted by 33 - 4 (within one scan line). For example, if you want the top of your display somewhere near the top of the monitor that'd be 33 - 4 + 34 = 63. R4 should have 33 - 4 added and if you set R9 to 0 on the VSYNC you'd need (39 - Normal VSYNC) * 7 added also, so R4 = 33 - 4 + 38 + (38 - 34) * 7 = 94. R6 would also need to be adjusted by 33 scan lines, so R6=33+28=61 for pretty well full overscan.

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 665
  • Liked: 269
Re: ghouls'n goblins gx4000
« Reply #78 on: 22:28, 29 February 16 »
So, i'm waiting for your example... I never use that way, but why not ?
Here goes. Not exactly demo of the year, but it probably gets the point across. Tweaking the DMA list REPEAT slightly can start the effect going in the other direction. Obviously you can get a lot more sophisticated with much longer DMA lists, causing different patterns of "movement" in the interrupt sequence by playing with the overall length and the spacing of interrupts.

Only tested in WinAPE, so hopefully not hitting any of the Plus bugs.  ;)

Code: [Select]
org &2000
run &2000

di

ld sp,&c000

;Unlock the ASIC so we can use Plus functionality
ld b,&bc
ld hl,bootasicsequence
ld e,17
seq:
ld a,(hl)
out (c),a
inc hl
dec e
jr nz,seq

; Put an EI;RET combo for the interrupt handler, so the firmware doesn't
; get in the way and start altering things
ld hl,&c9fb
ld (&0038),hl
ld (&8080),hl
di

;; enable asic ram (will be visible in range &4000-&7fff)
ld bc,&7fb8
out (c),c

; Reset the display file
ld bc, &bc0d
out (c),c
inc b
xor a
out (c),a
dec b
dec c
out (c),c
inc b
ld a, &30
out (c),a

; Put the display into MODE 0, ROMs disabled
ld bc,&7f8c
out (c),c

; Clear the screen
ld hl, &c000
ld de, &c001
ld bc, &3fff
xor a
ld (hl),a
ldir

; Set the border colour
xor a
ld hl,&6421
ld (hl),a
dec l
ld a, &6c
ld (hl),a

; Setup a DMA list
ld hl,dmalist
ld de,&8100
ld bc,dmalistend - dmalist
ldir

; Configure interrupts
ld hl,0
ld (&8000),hl
ld hl,0
ld (&8002),hl
ld hl,dma0int
ld (&8004),hl
ld hl,rasterint
ld (&8006),hl

ld a,1
ld (&6805),A ; Set the IVR to use a vector of 0, autoclear disabled
ld a,&80
ld i,a
im 2

; Configure a PRI at line 1
ld a,1
ld (&6800),A
ei

donothing: halt
jp donothing

rasterint:
; First time through, our Raster Int initializes the DMA
ld hl,&8100
ld (&6c00), hl ; Set our DMA list
ld a,1
ld (&6c0f), a ; Turn on DMA channel 0

; Set the raster int so it will no longer start the DMA list
ld hl,rasterint2
ld (&8006),hl

rasterint2:
ei
ret

dma0int:
; clear DMA interrupt
ld a,(&6c0f)
set 6,a
ld (&6c0f),a

; modify the border colour
ld a,(&6420)
rrca
rrca
ld (&6420), a

; keep count of how many interrupts we've serviced
ld a,(count)
inc a
ld (count),a
cp 4
jp nz, dma0intdone

; Once we've serviced them all, restart the DMA list
xor a
ld (count),a
ld hl,&8100
ld (&6c00), hl ; Reset our DMA list

dma0intdone: ei
ret

count: defb 0

dmalist:
defw &2000 + 312-20-1 ; Repeat (This is just enough to make our DMA list "too short")
defw &4001 ; Loop
defw &4010 ; Int
defw &1002 ; Pause 2
defw &4010 ; Int
defw &1004 ; Pause 4
defw &4010 ; Int
defw &1008 ; Pause 8
defw &4010 ; Int
defw &4020 ; STOP
dmalistend:

bootasicsequence:
defb &ff,&00,&ff,&77,&b3,&51,&a8,&d4,&62,&39,&9c,&46,&2b,&15,&8a,&cd,&ee

P.S. Was based on some cart code I had, which is why there is a little bit of redundant copying into bits of RAM....
« Last Edit: 22:30, 29 February 16 by andycadley »

Offline Ast

  • 6128 Plus
  • ******
  • Posts: 780
  • Country: fr
    • Amstrad cpc Website of Ast/iMPACT
  • Liked: 451
Re: ghouls'n goblins gx4000
« Reply #79 on: 22:47, 29 February 16 »
Here goes. Not exactly demo of the year, but it probably gets the point across. Tweaking the DMA list REPEAT slightly can start the effect going in the other direction. Obviously you can get a lot more sophisticated with much longer DMA lists, causing different patterns of "movement" in the interrupt sequence by playing with the overall length and the spacing of interrupts.

Only tested in WinAPE, so hopefully not hitting any of the Plus bugs.  ;)

Code: [Select]
org &2000
run &2000

di

ld sp,&c000

;Unlock the ASIC so we can use Plus functionality
ld b,&bc
ld hl,bootasicsequence
ld e,17
seq:
ld a,(hl)
out (c),a
inc hl
dec e
jr nz,seq

; Put an EI;RET combo for the interrupt handler, so the firmware doesn't
; get in the way and start altering things
ld hl,&c9fb
ld (&0038),hl
ld (&8080),hl
di

;; enable asic ram (will be visible in range &4000-&7fff)
ld bc,&7fb8
out (c),c

; Reset the display file
ld bc, &bc0d
out (c),c
inc b
xor a
out (c),a
dec b
dec c
out (c),c
inc b
ld a, &30
out (c),a

; Put the display into MODE 0, ROMs disabled
ld bc,&7f8c
out (c),c

; Clear the screen
ld hl, &c000
ld de, &c001
ld bc, &3fff
xor a
ld (hl),a
ldir

; Set the border colour
xor a
ld hl,&6421
ld (hl),a
dec l
ld a, &6c
ld (hl),a

; Setup a DMA list
ld hl,dmalist
ld de,&8100
ld bc,dmalistend - dmalist
ldir

; Configure interrupts
ld hl,0
ld (&8000),hl
ld hl,0
ld (&8002),hl
ld hl,dma0int
ld (&8004),hl
ld hl,rasterint
ld (&8006),hl

ld a,1
ld (&6805),A ; Set the IVR to use a vector of 0, autoclear disabled
ld a,&80
ld i,a
im 2

; Configure a PRI at line 1
ld a,1
ld (&6800),A
ei

donothing: halt
jp donothing

rasterint:
; First time through, our Raster Int initializes the DMA
ld hl,&8100
ld (&6c00), hl ; Set our DMA list
ld a,1
ld (&6c0f), a ; Turn on DMA channel 0

; Set the raster int so it will no longer start the DMA list
ld hl,rasterint2
ld (&8006),hl

rasterint2:
ei
ret

dma0int:
; clear DMA interrupt
ld a,(&6c0f)
set 6,a
ld (&6c0f),a

; modify the border colour
ld a,(&6420)
rrca
rrca
ld (&6420), a

; keep count of how many interrupts we've serviced
ld a,(count)
inc a
ld (count),a
cp 4
jp nz, dma0intdone

; Once we've serviced them all, restart the DMA list
xor a
ld (count),a
ld hl,&8100
ld (&6c00), hl ; Reset our DMA list

dma0intdone: ei
ret

count: defb 0

dmalist:
defw &2000 + 312-20-1 ; Repeat (This is just enough to make our DMA list "too short")
defw &4001 ; Loop
defw &4010 ; Int
defw &1002 ; Pause 2
defw &4010 ; Int
defw &1004 ; Pause 4
defw &4010 ; Int
defw &1008 ; Pause 8
defw &4010 ; Int
defw &4020 ; STOP
dmalistend:

bootasicsequence:
defb &ff,&00,&ff,&77,&b3,&51,&a8,&d4,&62,&39,&9c,&46,&2b,&15,&8a,&cd,&ee

P.S. Was based on some cart code I had, which is why there is a little bit of redundant copying into bits of RAM....

Ok, as i see you're using Ivr... Well Done and I've ever do that too :-P
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

Amstrad Plus :: Découverte de la gamme Old et Plus des Cpc d'Amstrad.
All friends are welcomed !