Jump to content

swapd0

Members
  • Content Count

    702
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by swapd0


  1. Another small update.

     

    I have a test program that draws several sprite with different bitmap depth, also I can scale some sprites. This is the part of the routine that check the sprite scale. if I remove this code, it it's more stable (It doesn't crash so often). So I think that with the GPUOBJ/OP Interrupts enabled, if there are some kind of pipeline stall it can break the code.

     

    	...
    	movei #$2020,r0
    	cmp r0,scale
    	jr EQ,continue_build_sprite
    	moveq #31,tmp			; branch op
    ; check alignment
    	and dst,tmp				; check 32bytes alignment
    	movei #align_last_sprite,r20
    	jump NE,(r20)
    	bset #SCALE_BIT,fields	; branch op
    continue_build_sprite:
    	...

     

     


  2. Small update, I'm using this code instead of bset & bclr to initialize the GPU and it's more stable, at least it works always the same way but it crashes when I draw the sprites with the GPU, but never if I use de 68000 with GPUOBJ.

     

     

    	movei #G_FLAGS,gpuFlagsPtr
    	; init gpu
    	movei   #(1<<7)+(1<<14),r1			; enable OBJ, reg page 1
        store r1,(gpuFlagsPtr)

     


  3. I'm using GPU interrupt to make a raster with a 4bits bitmap, but also I've a routine to change colors in the VI because if you do it in the middle of a frame you can get a wrong color. :(

     

    What I don't understand it's that some times it works, and later it doesn't.

     


  4. if I put this  bset #14,flags instead of  bclr #14,flags it works...


    I think that my jaguar init code it's wrong, I must something missing because sometimes it works, and other times it doesn't.

     

    init_jag:
    	move.w #$2700,sr                    ; disable all interrups
        move.w #$7fff,VI                    ; vbi off
    	lea stack_top,sp
    
    	lea dummy_irq,a0
    	move.l a0,LEVEL0.w
    
    	lea _BASE,a0
        move.l #$070007,d0                  ; big endian
        move.l d0,G_END-_BASE(a0)
        move.l d0,D_END
        moveq #0,d0
        move.l d0,G_CTRL-_BASE(a0)          ; stop gpu
        move.l d0,D_CTRL                    ; stop dsp
    	move.l #1<<14|%11111<<9,G_FLAGS-_BASE(a0)	; disable GPU-IRQs, bank #1
    ;	move.l #1<<14|%11111<<9,D_FLAGS				; disable DSP-IRQs, bank #1
    	move.l d0,D_FLAGS
    	move.l #%11111100000000,J_INT          ; clear and disable IRQs
    
        move.l #list,d0
        swap d0
        move.l d0,OLP-_BASE(a0)             ; set OP to STOP-OBJECT
    
        moveq #0,d0
        move.w d0,R_DAC
        move.w d0,L_DAC
        move.w d0,OBF-_BASE(a0)             ; clear OP-Flag
        move.l d0,BORD1-_BASE(a0)           ; border black
        move.w d0,BG-_BASE(a0)              ; background black
        move.l d0,PIT0-_BASE(a0)            ; stop PIT
        move.l d0,JPIT1                     ; stop JPIT1
        move.l d0,JPIT3                     ; stop JPIT2
        move.w #$1F01,INT1-_BASE(a0)        ; clear pending irqs & enable vbl
    
    ; blitter init
        lea A1_BASE,a0
        lea B_CMD,a1
    .cb0:
        move.l d0,(a0)+
        cmp.l a0,a1
        bne.s .cb0
    
        lea 4(a0),a0    ; skip B_CMD
        lea B_Z0+4,a1
    .cb1:
        move.l d0,(a0)+
        cmp.l a0,a1
        bne.s .cb1
    
    ; video init
        move.w CONFIG,d0               ; Also is joystick register
        andi.w #VIDTYPE,d0             ; 0 = PAL, 1 = NTSC
        beq.s .pal
    
        move.w #NTSC_HMID,d2
        move.w #NTSC_WIDTH,d0
        move.w #NTSC_VMID,d6
        move.w #NTSC_HEIGHT,d4
        bra.s .calc_values
    
      .pal:
        move.w #PAL_HMID,d2
        move.w #PAL_WIDTH,d0
        move.w #PAL_VMID,d6
        move.w #PAL_HEIGHT,d4
      .calc_values:
        move.w d0,d1
        asr.w #1,d1                   ; Width/2
        sub.w d1,d2                   ; Mid - Width/2
        add.w #4,d2                   ; (Mid - Width/2)+4
        sub.w #1,d1                   ; Width/2 - 1
        ori.w #$400,d1                ; (Width/2 - 1)|$400
        move.w d1,HDE
        move.w d2,HDB1
        move.w d2,HDB2
    
        move.w d6,d5
        sub.w d4,d5
    
        move.w d5,VDB
        move.w #$FFFF,VDE
    
        move.l #0,BORD1                ; Black border
        move.w #0,BG                   ; Init line buffer to black
    
        move.w #PWIDTH4|CSYNC|BGEN|RGB16|VIDEN,VMODE-_BASE(a0)  ; Configure Video
    	rts
    
    dummy_irq:
        move.w #$101,INT1		; clear vbl interrupt and enable it
        move.w #0,INT2			; restore interrupts ***
        rte
    

     


  5. Ok, this is my interrupt code. I'll have a look at your code to see what I'm doing wrong.

     

    	.gpu
    
    stack		.equr r31
    flagsAddr	.equr r29
    flags		.equr r28
    
    rasterAddr	.equr r0
    colors		.equr r1
    clut		.equr r2
    op			.equr r3
    col			.equr r4
    
    	.org G_RAM
    	.macro EMPTY_IRQ
    	.rept 8
    	nop
    	.endr
    	.endm
    
    ; this is the entry point of the GPU code
    cpu_interrupt:
    ;	IRQ 0
    	movei #init_raster,r0		; 3
    	movei #G_ENDRAM,stack		; 3
    	jump t,(r0)					; 1
    	moveta stack,stack			; 1
    
    dsp_interrupt:
    	EMPTY_IRQ
    timer_interrupt:
    	EMPTY_IRQ
    
    op_interrupt:
    	load (flagsAddr),flags			; GPU_FLAGS
    
    	load (rasterAddr),colors
    	movei #CLUT,clut
    
    ; 0, 1, 2, 3
    	loadp (colors),col
    	addqt #8,colors
    	storep col,(clut)
    	addqt #8,clut
    
    	storew op,(op)					; restore op
    	store colors,(rasterAddr)
    
    ; rte
        bclr #3,flags					; serviced
        bset #12,flags					; clear interrupt flag
    
    	load (stack),r30
        addqt #4,stack
    	addqt #2,r30
    	jump (r30)
    	store flags,(flagsAddr)			; restore interrupt
    
    	.long
    _raster_ptr::
    	dc.l 0
    
    init_raster:
    	movei #G_FLAGS,flagsAddr
    	movei #OBF,op
    	movei #_raster_ptr,rasterAddr
    
    	load (flagsAddr),flags
    	bset #7,flags
    	store flags,(flagsAddr)
    
        moveta rasterAddr,rasterAddr
    	moveta op,op
        moveta flagsAddr,flagsAddr
        subqt #4,stack
    
    ; fall to next included file (must be gpu_events.s)

     


  6. Also, I've checked and I don't smash any register, the interrupt runs in the alternative register bank and the main GPU code runs in the other. 

     

    Edit:

    IMO the bug is when I return from the interrupt, the GPU doesn't return to the correct address.

     


  7. This is driving me crazy.

     

    I have the GPU running into a tight loop waiting, here is the code:

    	...
    .wait_list:
        load (list_ptr),events
        cmpq #0,events
        jr EQ,.wait_list
        moveq #0,r0             ; don't f*ck parameters address at first iteration
    	...

    After that code I've inserted an infinite loop that changes the BG register.

     

    When I run the program it works ok because I'm not writing anything into list_ptr (== 0 always), but when I put a GPUOB the GPU interrupt is executed and I leave it with this code (same as docs). And then the background color start to change (returns after the tight loop), this means that the last addqt (???) it's not needed? It's a must because without it, some times it hangs.

     

    	...
    ; rte
        bclr #3,flags					; serviced
        bset #12,flags					; clear interrupt flag
    
    	load (stack),rts
    	addqt #4,stack
    	addqt #2,rts					; ???
    	jump (rts)
    	store flags,(flagsAddr)			; restore interrupt

     

    I don't know why this doesn't work, I've changed the way I was creating the OP list, and now I've a lot of problems when I've a GPU Object and some GPU code running.

     

    Memory dump for the OP list without GPUOB.

    Quote

    OP list 240 bytes, start at 0000eb10

    0000eb00 : 00000000 00000004   STOP

    0000eb08 : 55555555 55555555

    0000eb10 : 0000001d 600041c3   Jump if VC < top_line

    0000eb18 : 0000001d 60008f33.   Jump if VC > bottom_line

    0000eb20 : 01f4081d 663201c0.  Bitmap

    0000eb28 : 00000002 80a0b00c

    0000eb30 : 00c1581d 680001c0.  Bitmap

    0000eb38 : 00008000 2008806c

    0000eb40 : 00c2081d 6a000340.  Bitmap

    0000eb48 : 0000a000 200880eb

    0000eb50 : 00c3101d 6c040440.  Bitmap

    0000eb58 : 00008000 2008906c

    0000eb60 : 00c2101d 6e004540.  Bitmap

    0000eb68 : 0000a000 200890ab

    0000eb70 : 00c4b81d 70000640. Bitmap

    0000eb78 : 00008000 4010a06c

    0000eb80 : 00c5181d 72040740  Bitmap

    0000eb88 : 0000a000 4010a0ab

    0000eb90 : 00c5201d 74040840. Bitmap

    0000eb98 : 00008000 8020b06c

    0000eba0 : 00c5201d 7600c940. Bitmap

    0000eba8 : 0000a000 8020b0ab

    0000ebb0 : 00caa81d 78000a40. Bitmap

    0000ebb8 : 00008001 0040c06c

    0000ebc0 : 00d1281d 7a040b40. Bitmap

    0000ebc8 : 0000a001 0040c0ab

    0000ebd0 : 0113681d 7c228000. Bitmap

    0000ebd8 : 00000000 2000414c

    0000ebe0 : 00000000 00000004. STOP

    0000ebe8 : 55555555 55555555

    Memory dump OP List with GPUOB

    OP list 240 bytes, start at 0000eb08
    0000eb00 : 00000000 00000004 	STOP
    0000eb08 : 0000001d 600041c3    Jump if vc < top_line
    0000eb10 : 0000001d 60008f33    Jump if vc > bottom_line
    0000eb18 : 00000000 00000002 	GPUOB
    0000eb20 : 0115881d 663201c0 	Bitmap
    0000eb28 : 00000002 80a0b00c 
    0000eb30 : 00c1081d 68040290 	Bitmap
    0000eb38 : 00008000 2008806c 
    0000eb40 : 00c1081d 6a040410 	Bitmap
    0000eb48 : 0000a000 200880eb 
    0000eb50 : 00c2101d 6c040510 	Bitmap
    0000eb58 : 00008000 2008906c 
    0000eb60 : 00c2101d 6e040610 	Bitmap
    0000eb68 : 0000a000 200890ab 
    0000eb70 : 00c3181d 70040710 	Bitmap
    0000eb78 : 00008000 4010a06c 
    0000eb80 : 00c3181d 72040810 	Bitmap
    0000eb88 : 0000a000 4010a0ab 
    0000eb90 : 00c5201d 74040910 	Bitmap
    0000eb98 : 00008000 8020b06c 
    0000eba0 : 00c5201d 76040a10 	Bitmap
    0000eba8 : 0000a000 8020b0ab 
    0000ebb0 : 00c9281d 78040b10 	Bitmap
    0000ebb8 : 00008001 0040c06c 
    0000ebc0 : 00c9281d 7a040c10 	Bitmap
    0000ebc8 : 0000a001 0040c0ab 
    0000ebd0 : 0113681d 7c400000 	Bitmap
    0000ebd8 : 00000000 2000414c 
    0000ebe0 : 00000000 00000004 	STOP
    0000ebe8 : 55555555 55555555 

     

    • Confused 1

  8. IMHO try to save as much bandwidth as you can with 1, 2 or 4 bits bitmaps or the OP will eat all the bus cycles and you won't have enough free time for the 68000 to run the game logic loop.

    • Like 1
    • Confused 1

  9. The latest update (v.0.6.8) doesn't work on Mac, and doesn't show any error message. I had to install the older version.

     

    Now the old version doesn't work, but yesterday it was working. When I press the button to compile or run I only see "Activating extensions..." message.

     

    I've rebooted the computer and it works XD

    • Thanks 1

  10. I've been playing a bit with 7800basic and I'm stuck with a weird error.

     

    I've a function to check collisions with a 8x8 tile map, but since I'm using 16pixels zones the collision it's a bit weird because the tiles are 8x16 but they represents 4x8 tiles. hit_tile_xxx are arrays of data with a bitmask to check if you have to collided with the tile.

     

    I've a big wall on the left side of the screen, if I move the sprite there and then move it vertically I get the background color changing, and it's weird because I'm testing with temp1 that holds x position and I'm not moving on x axis.

     

    temp & 8 and temp & 4 are used to test if I'm in the left/upper or right/lower part of the tile.

     

    It looks like temp1 it's smashed with temp2 somewhere...

     

    Quote
    ; parameters, x, y
    function tile_collision
      tx = temp1 / 8
      ty = temp2 / 16
      tile = peekchar(screen1map, tx, ty, 20, 12)
      if tile = 0 then return 0
      tile = tile / 2. ; because of doublewide
      char1 = tile. ; debug 
      if temp2 & 8 then hit = hit_tile_high[tile] else hit = hit_tile_low[tile]. ; A
      if hit && (temp1 & 4) then BACKGRND = $5f : hit = hit_tile_right[tile] else BACKGRND = $1f : hit = hit_tile_left[tile]. ; B
      return hit

     

    Captura de pantalla 2021-02-15 a las 22.33.16.png


  11. 16 minutes ago, CloakeD said:

    In your first example is the (.) after next in your source code?

    No, it was a typo

     

    Also, why this doesn't work?

      if yenemy[i] = 16*8 then enemy_state[i] = STATE_MOVE

    but this works

      a = yenemy[i]
      if a = 16*8 then enemy_state[i] = STATE_MOVE

     


  12. This way I get no errors

     

    Quote
    enemy_ia
    for i = 0 to 7
    a = rand;enemy_state
    if a = 0 then gosub _egg : goto _loop_ia
    if a = 1 then gosub _hatch : goto _loop_ia
    if a = 3 then gosub _born : goto _loop_ia
    ; on a goto _egg, _hatch, _born
    _loop_ia
    next
    return
    _egg
    return
    _hatch
    return
    _born
    return

     


  13. Quote
    enemy_ia
      for i = 0 to 7
        a = enemy_state
        on a gosub _egg, _hatch, _born
      next.
      return
    _egg
      return
    _hatch
      return
    _born
      return

    How can I make this work?, I have also tried with on ... goto and then jump before the next but it doesn't work.

     

    Thanks


  14. 1 hour ago, SlidellMan said:

    Does it include Pro Controller support for those who wanted to develop with it in mind?

    There are no difference between a pro controller and a normal controller, it's impossible to detect which one is connected.

    • Like 2
    • Thanks 1

  15. CLUT it's taken from jaguar.h, it's defined like this, by the way I think that it should be a short * or int16_t*

     

    #define BASE 0xF00000 /* TOM Internal Register Base */

    #define CLUT  (long *)(BASE+0x400) /* Color Lookup Table */

     

    Anyway, it doesn't matter if the addition it's with a 16bit integer or a 32bits integer because there are no overflow. The palette is written by the 68000.

     

    The values that I shown before was the ones that I wrote to the CLUT, the source palette or *color values if you like, I didn't read the CLUT. Later I can try to compare each write with the source value and log if there are a different value.

     

×
×
  • Create New...