diff --git a/KernelRoutineList.txt b/KernelRoutineList.txt index e709b71..f8e0da1 100644 --- a/KernelRoutineList.txt +++ b/KernelRoutineList.txt @@ -28,6 +28,8 @@ Hardware.s +- vram_dump Int.s + | + +- int16_add_byte Irq.s | diff --git a/a.out b/a.out index 888d99b..a811587 100644 Binary files a/a.out and b/a.out differ diff --git a/main.s b/main.s index 5a4f46b..3b65156 100644 --- a/main.s +++ b/main.s @@ -44,14 +44,38 @@ reset: sei stz system_register stz soft_system_register - jsr video_writeline_static - .string "Hello World" + ;jsr video_writeline_static + ;.string "Hello World" + jsr video_clear - jsr kernel_init + ldx #charset + jsr video_load_font + lda #$f0 + jsr irq_init -loop: jmp loop + stz k0 + lda #$00 + tax + tay + +lp: + lda k0 + jsr vram_write + + inc k0 + inx + cpx #$10 + bne lp + ldx #$00 + iny + cpy #$10 + bne lp + +loop: + jmp loop irq_jump: jmp (irq_vector) diff --git a/src/kernel.s b/src/kernel.s index 88b2b14..6421f8f 100644 --- a/src/kernel.s +++ b/src/kernel.s @@ -6,8 +6,4 @@ .include "src/kernel/event_handler.s" .include "src/kernel/memory_manager.s" .include "src/kernel/hardware.s" - -kernel_init: - rts - \ No newline at end of file diff --git a/src/kernel/hardware.s b/src/kernel/hardware.s index c60ba78..07541ed 100644 --- a/src/kernel/hardware.s +++ b/src/kernel/hardware.s @@ -34,11 +34,13 @@ vram_write_color: ; Output: (none) - ; I'm deliberately NOT using Kernel Stack here, - ; for more speed and efficiency and because It's just one Byte - + ; I'm deliberately NOT using the Kernel Stack here, + ; for more speed and efficiency and because it's just two Bytes ;) + + phx ; Push X to Stack pha ; Push A to Stack txa ; Transfer X to A for Math + clc adc #$40 ; Add #$40 (Color Range) plx ; Pop Stack to X @@ -51,6 +53,8 @@ vram_write_color: nop nop sta vidx ; Sets Read Mode + txa + plx rts diff --git a/src/kernel/int.s b/src/kernel/int.s index e69de29..52ecf56 100644 --- a/src/kernel/int.s +++ b/src/kernel/int.s @@ -0,0 +1,50 @@ +int16_add_byte: + ; Int16 add Int8 + + ; Input: + ; A <= Least significant Byte + ; X <= Most sifnificant Byte + ; Y <= Byte to add + + ; Output: + ; A <= Least significant Byte + ; X <= Most significant Byte + + clc + sty k0 + adc k0 + bvc int16_add_byte_return + inx + +int16_add_byte_return: + rts + +int16_increment_pointer: + ; Int16 Increment from Pointer + + ; Input: + ; X => LOW Pointer Byte + ; Y => HIGH Pointer Byte + + ; Output: (none) + + rts + +int16_increment: + ; Int16 Increment + + ; Input: + ; X => LSB -byte + ; Y => MSB -byte + + ; Output: + ; X <= LSB -byte + ; Y <= MSB -byte + + clc + inx + bcc int16_increment_return + iny + +int16_increment_return: + rts \ No newline at end of file diff --git a/src/kernel/irq.s b/src/kernel/irq.s index 8f68675..54ff2ed 100644 --- a/src/kernel/irq.s +++ b/src/kernel/irq.s @@ -8,13 +8,12 @@ irq_init: ; Output: (none) - sta t1ch - - lda #$40 - sta acr + ldx #$40 + stx acr stz t1cl - lda #$00 - sta ier + sta t1ch + ldx #$c0 + stx ier cli rts @@ -35,11 +34,25 @@ irq: sty irq_y + jsr keyboard_scan + phx + phy + + ldx #$11 + ldy #$11 + jsr vram_write + + pla + inx + jsr vram_write + + pla + inx + jsr vram_write bit t1cl ; "Ping" VIA Timer, to trigger Restart lda irq_a ; Restore A, X, Y and Processor Status ldx irq_x ldy irq_y plp - rti \ No newline at end of file diff --git a/src/kernel/keyboard.s b/src/kernel/keyboard.s index a50a4b2..d268460 100644 --- a/src/kernel/keyboard.s +++ b/src/kernel/keyboard.s @@ -11,6 +11,65 @@ keyboard_scan: ; Y <= Arrow Keys + + + + + + + + rts + + + + + lda soft_system_register + and #$f8 + sta soft_system_register + sta system_register + + ldy #$00 ; Result Index + ldx #$00 ; Row Counter + +keyboard_scan_load: + lda #$fe ; Bit shifter + +keyboard_scan_loop: + cmp keyboard_port + beq keyboard_scan_return + iny + rol + cmp #$fe + bne keyboard_scan_loop + inx + cpx #$08 ; Checking if Counted to 7 + beq keyboard_scan_return + + + inc soft_system_register + lda soft_system_register + sta system_register + + jmp keyboard_scan_load + +keyboard_scan_return: + sty k0 + lda soft_system_register + ora #$05 + sta system_register + lda keyboard_port + tax + and #$0f + tay ; => Arrow Keys + txa + rol + rol + rol + rol + and #$07 + + tax ; => Modifier Keys + lda k0 ; => Scancode rts keyboard_translate: @@ -39,4 +98,8 @@ keyboard_format: ; A <= ASCII Char - rts \ No newline at end of file + rts + + +keyboard_ascii_lookup: + .byte $80 ; bla bla bla \ No newline at end of file diff --git a/src/kernel/video.s b/src/kernel/video.s index 6005a34..c63fec2 100644 --- a/src/kernel/video.s +++ b/src/kernel/video.s @@ -10,6 +10,56 @@ video_write: ; Output: (none) + stx z0 + sty z1 + + ; y => counter + ; x => X Coords + ; K0 => Y Coords + +video_write_loop: + lda (z0), y + iny + cmp #$00 + beq video_write_return + cpy #$00 + beq video_write_return + + phy + + lda #$30 + cmp cursor_x + bcc video_write_skip_overflow + stz cursor_x + inc cursor_y + + lda #$20 + cmp cursor_y + bcc video_write_skip_overflow + + lda #$00 + jsr video_scroll + lda #$1f + sta cursor_y + +video_write_skip_overflow: + ldx cursor_x + ldy cursor_y + jsr vram_write + + ; cursor checking bla bla + + inc cursor_x + ply + jmp video_write_loop + +video_write_return: + ; calc new address and put into xy + lda z0 + ldx z1 + jsr int16_add_byte + + rts @@ -21,6 +71,13 @@ video_write_static: ; Input: (none) ; Output: (none) + plx + ply + jsr video_write + + ; if return right + phy + phx rts @@ -35,6 +92,8 @@ video_writeline: ; Output: (none) + jsr video_write + jsr video_return ; or new video_newline rts @@ -176,8 +235,27 @@ video_scroll: video_clear: ; Video Clear - ; Clears the Screen blank, with the normal Color + ; Clears the Screen blank, with the normal Color and #$20 Chars + ; Input: (none) + ; Output: (none) + + ldx #$00 + ldy #$00 + +video_clear_loop: + lda #$20 + jsr vram_write + lda color + jsr vram_write_color + + inx + cpx #$30 + bne video_clear_loop + ldx #$00 + iny + cpy #$00 + bne video_clear_loop rts @@ -213,5 +291,26 @@ video_load_font: ; Output: (none) + stx z0 + sty z1 + ldx #$78 + ldy #$00 + +video_load_font_loop: + lda (z0) + jsr vram_write + inx + inc z0 + bne video_load_font_check + inc z1 + +video_load_font_check: + cpx #$80 + bne video_load_font_loop + ldx #$78 + iny + cpy #$00 + bne video_load_font_loop + rts \ No newline at end of file