Add documentation.

This commit is contained in:
giomba 2022-11-04 21:02:53 +01:00
parent a5b5fb17c6
commit 05f231d8ba
3 changed files with 21 additions and 15 deletions

22
const.h
View File

@ -1,15 +1,21 @@
#pragma once
#define FRAME_PIXEL_WIDTH 1024 // [system clock]
#define FRAME_PIXEL_HEIGHT 256 // [line]
#define FRAME_SYSCLOCK_WIDTH 1024 // [sysclock]
#define FRAME_LINE_HEIGHT 256 // [line]
#define BACK_PORCH_OFFSET 100 // [system clock]
#define FRONT_PORCH_OFFSET 40 // [system clock]
#define BACK_PORCH_SYSCLOCK_OFFSET 80 // [sysclock]
#define FRONT_PORCH_SYSCLOCK_OFFSET 40 // [sysclock]
#define SPRITE_WIDTH 80 // [system clock]
#define SPRITE_HEIGHT 64 // [line]
#define SPRITE_PIXEL_WIDTH 80 // [sysclock]
#define SPRITE_LINE_HEIGHT 64 // [line]
#define SYSCLOCK_PER_PIXEL 4
#define SPRITE_SYSCLOCK_WIDTH (SPRITE_PIXEL_WIDTH * SYSCLOCK_PER_PIXEL)
// Time spent from the horizontal sync pulse,
// to the first displayed dot.
// This is given as HSYNC_INT_TUNE + HSYNC_TIMER_TUNE + C part
#define HSYNC_TUNE 70
// This is given as the sum of:
// + HSYNC_INT_TUNE
// + HSYNC_TIMER_TUNE
// + sysclock duration of "C" interrupt part
#define HSYNC_SYSCLOCK_TUNE 70 // [sysclock] (approx)

4
main.S
View File

@ -64,7 +64,7 @@ int_horizontal_sync_s:
; total: 25
; HSYNC_INT_TUNE = 25
; this adds up for HSYNC_TUNE
; this adds up for HSYNC_SYSCLOCK_TUNE
pop r30
pop r31
@ -107,7 +107,7 @@ int_timer_1:
; total: 39
; HSYNC_TIMER_TUNE = 39
; this adds up for HSYNC_TUNE
; this adds up for HSYNC_SYSCLOCK_TUNE
.global jump_table_return_address
jump_table_return_address:

10
main.c
View File

@ -39,12 +39,12 @@ ISR(INT0_vect) {
// invert bouncing direction
if (vpos == 0)
vinc = +1;
if (vpos == FRAME_PIXEL_HEIGHT - SPRITE_HEIGHT)
if (vpos == FRAME_LINE_HEIGHT - SPRITE_LINE_HEIGHT)
vinc = -1;
if (hpos == BACK_PORCH_OFFSET)
if (hpos == BACK_PORCH_SYSCLOCK_OFFSET)
hinc = +1;
if (hpos ==
FRAME_PIXEL_WIDTH - SPRITE_WIDTH - FRONT_PORCH_OFFSET - HSYNC_TUNE)
if (hpos == FRAME_SYSCLOCK_WIDTH - SPRITE_SYSCLOCK_WIDTH -
FRONT_PORCH_SYSCLOCK_OFFSET - HSYNC_SYSCLOCK_TUNE)
hinc = -1;
int_vertical_sync_s();
@ -57,7 +57,7 @@ ISR(INT1_vect) {
line += 1;
// we are past the last line of the sprite
if (line >= vpos + SPRITE_HEIGHT)
if (line >= vpos + SPRITE_LINE_HEIGHT)
return;
if (line >= vpos)