Help needed for "Frames Per Second Counter / Monitor"

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
MrSterlingBS
Vic 20 Enthusiast
Posts: 174
Joined: Tue Jan 31, 2023 2:56 am
Location: Germany,Braunschweig

Help needed for "Frames Per Second Counter / Monitor"

Post by MrSterlingBS »

Dear all,

after implementing the 3DCube Demo from https://retro64.altervista.org/blog/an- ... d-objects/ i think about a frames per second counter to know how many frames the routine is working.

My routine look like this:

Code: Select all

	SEI				; new Interrupt-Service-Routine @ IRQ
	LDA #<IRQ
	STA $0314
    	LDA #>IRQ
    	STA $0315
	LDA #$3C			; store 60 to cycle counter to CC
	STA CC
	LDA #$00			; set FPS to zero for initial
	STA FPS	
	CLI
    	;RTS

MainLoop:
	INC FPS
	3D-Cube calculation
	Drawing
	...
	JMP MainLoop
		

IRQ:
	DEC CC			; decrement cycle counter
	BNE Back		; no, then back to program
	LDA #$3C		; reset cycle counter to 60
	STA CC			; 
	LDA FPS			; load FPS value
	STA $1280		; show FPS to screen/bitmap
	LDA #$00		; reset FPS value to zero
	sta FPS
	lda #%10101010		; just to show and count the bit pattern
	sta $1281
	lda #%01010101
	sta $1282
Back:
	JMP $EABF
The screen shows this:
vice-screen-2023120218294730.png
vice-screen-2023120218294730.png (1.92 KiB) Viewed 2772 times
The bit-pattern in the first line shows 00010001. That is decimal 17.
The second and third bit-pattern is only for counting the bits in the first line.

My question is, is this interrupt routine correct?
Can the jump to the $EABF routine be implemented differently?
Where is the return of routine $EABF stored?

Thanks a lot for your help.

Best regards,
Sven
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Help needed for "Frames Per Second Counter / Monitor"

Post by srowe »

MrSterlingBS wrote: Sat Dec 02, 2023 11:46 am My question is, is this interrupt routine correct?
Can the jump to the $EABF routine be implemented differently?
That depends on what you want happen during an interrupt.

The KERNAL routine is this

https://eden.mose.org.uk/gitweb/?p=rom ... AD#l10602

it's designed to handle the following
  • updating the real time clock
  • flashing the cursor if keyboard input is in progress
  • controlling the cassette motor
if none of these are relevant to your program you can just pull the saved registers and return rather than calling it.
Where is the return of routine $EABF stored?
It causes the system to return to the point the interrupt occurred, which is stored on the stack.
User avatar
MrSterlingBS
Vic 20 Enthusiast
Posts: 174
Joined: Tue Jan 31, 2023 2:56 am
Location: Germany,Braunschweig

Re: Help needed for "Frames Per Second Counter / Monitor"

Post by MrSterlingBS »

Thanks a lot for the tip. I found what i need.
If i use the following code or jump to $EB15 instead the jump to $EAFB it works perfect for my routine.

Code: Select all

	
	BIT $9124
	PLA
	TAY
	PLA
	TAX
	PLA
	RTI	
User avatar
MrSterlingBS
Vic 20 Enthusiast
Posts: 174
Joined: Tue Jan 31, 2023 2:56 am
Location: Germany,Braunschweig

Re: Help needed for "Frames Per Second Counter / Monitor"

Post by MrSterlingBS »

There is a minor update of the code.
Now the FPS shows in decimal numbers, but only from 00-29 FPS.
I think this is enough...
vice-screen-2023120318182725.png
vice-screen-2023120318182725.png (1.45 KiB) Viewed 2689 times
User avatar
MrSterlingBS
Vic 20 Enthusiast
Posts: 174
Joined: Tue Jan 31, 2023 2:56 am
Location: Germany,Braunschweig

Re: Help needed for "Frames Per Second Counter / Monitor"

Post by MrSterlingBS »

Here is the sample code with hidden lines... over 22FPS ??? Can this be?
3D-Cube.zip
(2.68 KiB) Downloaded 71 times
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Help needed for "Frames Per Second Counter / Monitor"

Post by Mike »

MrSterlingBS wrote:Can this be?
I do not think you have a good reason to distrust this number.
Post Reply