Author Topic: Drawing a gradient on the CPC+ with interrupts  (Read 284 times)

0 Members and 1 Guest are viewing this topic.

Offline Cwiiis

  • CPC664
  • ***
  • Posts: 141
  • Country: gb
    • Blog
    • Awards
Drawing a gradient on the CPC+ with interrupts
« on: 22:52, 15 August 21 »
I'm experimenting with Plus features and wanted to draw a vertical gradient - to do this I'm using the RPI - so I can't start on line zero, which is fine... I'm seeing some weird behaviour though. Sometimes I get crashes on repeated runs and it seems adjusting the timing can make all sorts of unexpected things happen... But I don't understand why the timing of what I'm doing should make any difference to anything except what's displayed?

Anyway, that aside, as I understand it, drawing a line takes 64 nops. My main loop is like so;
Code: [Select]
          halt          ; Wait for interrupt

      SKIP 64-7-2

          MAP_PLUS(1)   ; [7]

          ld a,0        ; [2]

          ld hl,&6400   ; [3] Write palette entry 0
          ld (hl),a     ; [2]
          inc hl        ; [2]
          ld (hl),0     ; [3]

      SKIP 63-3-2-2-3-1-2-2 ; 63... What am I missing?

          inc a         ; [1]
          cp 16         ; [2]
          jr nz,GradientIntLoop ; [2]


          ; Check for user pressing ESC
          ld a,KeyLine8
          call ScanKeyboardLine
          bit Key_Esc,a
          jp nz,MainLoop

If I change the line that starts with '63-' to '64-' as I would've expected, the palette change introduces a diagonal seam, indicating that it's happening too late - have I gotten the timings wrong on the operations in GradientIntLoop?

I'm assuming some of my instability is due to me not restoring state correctly - I set the PRI to zero and restore the original word at &0038, is there something else/more I might be missing?
No reactions

Offline m_dr_m

  • 464 Plus
  • *****
  • Posts: 326
  • Country: gb
    • OrgaMS!
    • Awards
Re: Drawing a gradient on the CPC+ with interrupts
« Reply #1 on: 01:21, 16 August 21 »
1/ The jr is [3] when looping. See

2/ Don't use SKIP but FILL size,0 or size ** NOP.  Otherwise you will end up with previous spurious opcodes when re-assembling! (that would explain the weird crashes)
Or use a tempo macro like in

« Last Edit: 01:24, 16 August 21 by m_dr_m »
No reactions