Jump to content
IGNORED

Scrolling (from memory buffer) and > 256 characters


mksmith

Recommended Posts

  • 2 weeks later...
On 7/3/2022 at 10:15 PM, Eagle said:

Hmm 7000 cycles, not great, not terrible :D 

Welp, If you do 114*70 (If the screen is 192 lines, VBLANK is 70) then you get 7,980 cycles, or almost 8 KHZ per frame to work with. Now, with low DMA levels you could get more, like if you had 40 cycles at the end to work with, then that would be 15660 cycles in all...

 

On the bright side, 

Link to comment
Share on other sites

It's excellent for sure. I really want to see how I can fit it into 7800basics DL setup but even if it can sit on top that would be great too. Very much quicker and cleaner than my attempt ?

 

  • Like 3
Link to comment
Share on other sites

You could use 16K RAM at $4000 and using 8K of the RAM, you can get 256*16 2byte wide 160B tiles. It's what I'm going to do for It's Conner Time 2.

Edit: I think I'll not use that because 160B uses way too much DMA. Unless direct mode can save me, 160A it is.

Edited by Ecernosoft
Link to comment
Share on other sites

On 8/2/2022 at 8:40 AM, TwentySixHundred said:

I will be having some fun reading the source to try and work out exactly how this is achieved.

 

Turrican scroll - emulator link JS7800

 

If you want more fun then I attached source code for Circular scroll with decoding Tiles 4x4 from CharpadPro

Have fun :D

 

		mwa #$00 scroll		;scroll counter=0
		
		mwa #map sour
		mwa #tiles	sour_tile
main  		
		jsr WaitVBLANK
		inw scroll			;incrase word size
		jsr update_scroll
		jsr copy_scroll
		jmp main

	.macro put_4_lines
		lda :1
		and #$0f
		:+4 asl @
		sta temp

		lda :1
		and #$F0
		:+4 lsr @
		clc 
		adc #>tiles		;tile address
		sta temp+1

		ldy TileX
		lda (temp),y
		sta :2+$100+32,x
		sta :2+[$100+32]-256,x	;duplicate for cirular buffor
		:+4 iny
		lda (temp),y
		sta :2+$300+32,x
		sta :2+[$300+32]-256,x
		:+4 iny
		lda (temp),y
		sta :2+$500+32,x
		sta :2+[$500+32]-256,x
		:+4 iny
		lda (temp),y
		sta :2+$700+32,x
		sta :2+[$700+32]-256,x
		.endm
 

	.use DLLs
	

copy_scroll
		mwa scroll temp
		lsr temp+1 
		ror temp
		lsr temp+1 
		ror temp	;divide word/4

		lda temp
		tax
		and #$03
		sta TileX
;

		lsr temp+1
		ror temp
		lsr temp+1 
		ror temp	;divide word/4
		lda temp
		clc
		adc #<map
		sta temp
		lda temp+1
		adc #>map
		sta temp+1
		ldy #$00
		lda (temp),y
		sta buffer			;extract tile number
		adw temp #600 temp	;add 600 (tile 4x4 map width) - next line
		lda (temp),y
		sta buffer+1		;extract tile number
		adw temp #600 temp
		lda (temp),y
		sta buffer+2		;extract tile number
		adw temp #600 temp
		lda (temp),y
		sta buffer+3		;extract tile number
		adw temp #600 temp
		lda (temp),y
		sta buffer+4		;extract tile number

		put_4_lines buffer,$4000
		put_4_lines buffer+1,$4800
		put_4_lines buffer+2,$5000
		put_4_lines buffer+3,$5800
		put_4_lines buffer+4,$6000
		rts

 

Scroll4x4.zip

Edited by Eagle
  • Like 3
  • Thanks 2
Link to comment
Share on other sites

@Traxx No problem, on 7800 you have DLI so is much easier then on C64

If you want full version let me now and how many changes you want (every line, every 4 lines, etc.)

 

change bit 7 in DLL

DLLs
	:3	.byte	$0F,>emptyline,<emptyline	;3 empty DLL

		.byte	$87,>line1,<line1	;$87 - 8 lines + interrupt - bit 7 set DLI 
		.byte	$87,>line2,<line2
		.byte	$87,>line3,<line3
		.byte	$87,>line4,<line4
		.byte	$87,>line5,<line5
		.byte	$87,>line6,<line6
		.byte	$87,>line7,<line7
		.byte	$87,>line8,<line8
        ....
        ....
        ....

 

and then something like this

 

Dlivect	= $f0	;any address in RAM
;
; on beginning of the program
	....
	mwa #dli1 Dlivect
	....

;
NMI
	jmp (dlivect)

DLI1
	pha
	lda #>fnt1	;first charset
	sta wsync
	sta chbase
	mwa #DLI2 dlivect
	pla
	rti

DLI2
	pha
	lda #>fnt2	;second charset
	sta wsync
	sta chbase
	mwa #DLI3 dlivect
	pla
	rti

DLI3
.....
.....
.....

	last DLI have to set Dlivect = DLI1

 

 

Edited by Eagle
  • Like 4
  • Thanks 1
Link to comment
Share on other sites

IMHO indirect mode scroll is not what A7800 should do, because of DMA and colours.

Direct mode is right way to use capabilities of A7800.

So today another scroll example for you guys, it's not beautiful but it works 

I'm using Pokey random numbers to generate screen and choose pallets 

I was to lazy to put nice gfx from Kirby or Mario, so you can see only numbers (instead you have to use your imagination ;) ) 

Enjoy

 

ps. You read at your own risk  :D 

 

Direct scroll - JS7800 emulator link

 

 

image.thumb.png.017fed1106034012474f229fb9c35986.png

 

main  		
		jsr WaitVBLANK
		:40 sta wsync 		;wait 40 lines to show cpu usage
		mva #$0a BACKGRND

		jsr update_scroll
		jsr reset_row

		mva #$00 BACKGRND
		jmp main


update_scroll
		:170 change_x Line1,#	;decrase 170 times xpos (warning: also using 4th byte of DL_End, but DL need only two zeros)
		rts
reset_row 
		mwa #line1 sour	
		ldy #$03	;+3 - xpos in DL
		ldx #$00
@		
		lda (sour),y
		cmp #$F4
		beq @+ 
		adw sour #$04
		inx
		cpx #16
		bne @-		
		rts
		
@	:10	write_row 	;write 10 times
		rts

	;parametr :1 - address DL line, +3 (xpos in DL)
	;parametr :2 - #*4 (# - loop counter) skip 4 bytes to next DL
	;to make ?easier? for this example, DL_End is !!!4 bytes!!! instead of 2 bytes (sorry)

		.macro change_x 
		dec :1+3+[:2*4]
		.endm		
		.macro write_row 
		lda #180		;xpos = 180 after tile is disappear on left side
		ldy #$03		;xpos in DL
		sta (sour),y
		
;don't look down :)
;this is only for draw new tiles
;
;choose random Tile
		lda Random
		and #$0F		;from 0-15
;multiply x3 because Tiles are 3 bytes width
		sta temp		;=*1
		asl @			;=*2
		clc
		adc temp		;=*3 
;
		ldy #$00		;update LSB 
		sta (sour),y
;get random pallet for Tile
		lda Random
		and #$E0		;we use only highest 3 bits for pallet
		ora #$1D		;ora width of tile (3 bytes)
		ldy #$01		;update pallet
		sta (sour),y
		adw sour #[17*4]	;16 DL*4bytes in one DL line + 2 zero ending DL + 2 extra zero to simplify math
		.endm

 

directmodescroll.a78 DirectScrollSourceCodeMads.zip

  • Like 6
Link to comment
Share on other sites

Today direct mode scroll (25 colours) + 16 sprites (25 colours) 

I just merged my very old proc with scroll and it works

Sorry for any brain damage trying to understand how it works (because I have no clue :D

Enjoy

 

Direct scroll + 16 sprites in 25 colours - link to emulator JS7800

 

 

main  		
		jsr WaitVBLANK
		mva #$0a BACKGRND	;show CPU usage

		jsr update_scroll
		jsr reset_row
		jsr Clear_all_sprites		;delete all srites from previous Vblank (put $00 in second byte after scroll/background data)
		jsr	put_sprites_on_screen 
		jsr Sinus_path
		mva #$00 BACKGRND
		jmp main


put_sprites_on_screen 
	ldx #$00
	
loop_put_sprites_on_screen 	
	lda tab_en,x
	stx reg_x
	beq skip_put_sprite 
	jsr put_sprite
skip_put_sprite 
	ldx reg_x
	inx
	cpx #16
	bne loop_put_sprites_on_screen
	rts


Sinus_path 
	inc sin_count
	
	lda	sin_count
	tax
	ldy #$0f
loop_sinus 
	lda	sinus,x
	clc
	adc #20		;center sprites
	sta x_en,y
	txa
	clc
	adc #25
	tax
	lda	sinus,x
	sta	y_en,y
	txa
	clc
	adc #15
	tax
	dey
	bpl loop_sinus
	rts

;This time we update only DL for scrolling parts
update_scroll
		:16 change_x Line1,#
		:16 change_x Line2,#
		:16 change_x Line3,#
		:16 change_x Line4,#
		:16 change_x Line5,#
		:16 change_x Line6,#
		:16 change_x Line7,#
		:16 change_x Line8,#
		:16 change_x Line9,#
		:16 change_x Line10,#
		rts

reset_row 
		mwa #line1 sour	
		ldy #$03	;+3 - xpos in DL
		ldx #$00
@		
		lda (sour),y
		cmp #$F4
		beq @+ 
		adw sour #$04
		inx
		cpx #16
		bne @-		
		rts
		
@	:10	write_row 	;write 10 times
		rts

	;parametr :1 - address DL line, +3 (xpos in DL)
	;parametr :2 - #*4 (# - loop counter) skip 4 bytes to next DL
	;to make ?easier? for this example, DL_End is !!!4 bytes!!! instead of 2 bytes (sorry)

		.macro change_x 
		dec :1+3+[:2*4]
		.endm

		.macro write_row 
		lda #180		;xpos = 180 after tile is disappear on left side
		ldy #$03		;xpos in DL
		sta (sour),y
		
;don't look down :)
;this is only for draw new tiles
;
;choose random Tile
		lda Random
		and #$0F		;from 0-15
;multiply x3 because Tiles are 3 bytes width
		sta temp		;=*1
		asl @			;=*2
		clc
		adc temp		;=*3 
;
		ldy #$00		;update LSB 
		sta (sour),y
;get random pallet for Tile
		lda Random
		and #$E0		;we use only highest 3 bits for pallet
		ora #$1D		;ora width of tile (3 bytes)
		ldy #$01		;update pallet
		sta (sour),y
		adw sour #[33*4]	;16 DL*4bytes in one DL line +16 DL*4bytes for sprites + 2 zero ending DL + 2 extra zero to simplify math
		.endm

	.macro	tablica_line
	.word [:1],[:1+4],[:1+8],[:1+12],[:1+16],[:1+20],[:1+24],[:1+28],[:1+32],[:1+36],[:1+40],[:1+44],[:1+48],[:1+52],[:1+56],[:1+60]
	.endm

;Sprite addreses in DL line after scroll DL 
tab_line 
	tablica_line line1+64
	tablica_line line2+64
	tablica_line line3+64
	tablica_line line4+64
	tablica_line line5+64
	tablica_line line6+64
	tablica_line line7+64
	tablica_line line8+64
	tablica_line line9+64
	tablica_line line10+64


;put $00 in second byte (dl end)
Clear_all_sprites
	lda #$00
	sta Line1+1+64
	sta Line2+1+64
	sta Line3+1+64
	sta Line4+1+64
	sta Line5+1+64
	sta Line6+1+64
	sta Line7+1+64
	sta Line8+1+64
	sta Line9+1+64
	sta Line10+1+64

	ldx #$0F
	lda #$00
loop_spr_count
	sta spr_count,x
	dex
	bpl loop_spr_count
	rts
	

put_sprite 
; I have no idea how this work :) I did this long time ago and now merged with scroll and it's working 
; I translate some comments from Ponglish to English :D Enjoy
;
	ldy y_en,x		;Y position
	sty adc_temp	;copy
	lda tab_y,y 	;address dll
	sta reg_a
	ldx tab_spr_count,y
	lda spr_count,x
	inc spr_count,x
	asl @
	clc
	adc reg_a
	tay

	lda tab_line,y
	sta dest
	lda tab_line+1,y
	sta dest+1

	ldy #$00
	ldx reg_x
	lda tab_faz,x 	;sprite address (you can use for sprite animation)
	sta (dest),y
	iny
	lda spr_color,x	;pallet number and width sprite
	sta (dest),y
	iny

	lda adc_temp
	and #$0f
	clc
	adc #>[sprite_data]
	sta (dest),y
	iny
	lda x_en,x		;x sprite
	sta (dest),y
	iny
	iny
	lda #$00		;write $00 to mark end DL
	sta (dest),y
	
	lda adc_temp
	clc
	adc #16
	sta adc_temp
	tay

	lda tab_y,y ;adres dll
	sta reg_a	
	ldx tab_spr_count,y
	lda spr_count,x
	inc spr_count,x
	asl @
	clc
	adc reg_a
	tay
	
	lda tab_line,y
	sta dest
	lda tab_line+1,y
	sta dest+1
	ldy #$00
	ldx reg_x
	lda tab_faz,x		;sprite address (you can use for sprite animation)
	sta (dest),y
	iny
	lda spr_color,x		;pallet number and width sprite
	sta (dest),y
	iny
	lda adc_temp
	and #$0f
	sec
	sbc #$10
	clc
	adc #>[sprite_data]
	sta (dest),y
	iny
	lda x_en,x		;x sprite
	sta (dest),y
	iny
	iny
	lda #$00	;write $00 to mark end DL
	sta (dest),y
	rts

tab_y 
	:16 .byte 0
	:16 .byte $20
	:16 .byte $40
	:16 .byte $60
	:16 .byte $80
	:16 .byte $a0
	:16 .byte $c0
	:16 .byte $e0
tab_spr_count 
	:16 .byte 0
	:16 .byte 1
	:16 .byte 2
	:16 .byte 3
	:16 .byte 4
	:16 .byte 5
	:16 .byte 6
	:16 .byte 7
tab_msb 
	:8	.byte 0
	:8	.byte 1
	:8	.byte 2
	:8	.byte 3
	:8	.byte 4
	:8	.byte 5
	:8	.byte 6
	:8	.byte 7
	:8	.byte 8
	:8	.byte 9
	:8	.byte 10
	:8	.byte 11
	:8	.byte 12
	:8	.byte 14
	:8	.byte 15

;address of sprites from 0 to 15 in sprite_bank
tab_faz 
	.byte 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45

 

DirectScrollSpritesSourceCodeMads.zip directmodescroll.a78

  • Like 6
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...