├── isr ├── irq_timing.sav ├── isr.elf ├── isr.gba ├── isr.sav ├── build │ ├── isr.o │ ├── isr.d │ ├── text.o │ └── text.d ├── Makefile └── source │ ├── isr.s │ └── text.s ├── README.md ├── if_ack ├── if_ack.elf ├── if_ack.gba ├── if_ack.sav ├── build │ ├── text.o │ ├── if_ack.o │ ├── text.d │ └── if_ack.d ├── source │ ├── if_ack.s │ └── text.s └── Makefile ├── experimental ├── readme.md ├── pcmxx │ ├── build │ │ ├── main.d │ │ ├── text.d │ │ ├── main.o │ │ └── text.o │ ├── pcmxx.elf │ ├── pcmxx.gba │ ├── pcmxx.sav │ ├── source │ │ └── main.s │ └── Makefile ├── joypad │ ├── build │ │ ├── text.d │ │ ├── text.o │ │ ├── joypad.d │ │ └── joypad.o │ ├── joypad.elf │ ├── joypad.gba │ ├── joypad.sav │ ├── source │ │ └── joypad.s │ └── Makefile ├── irq_delay │ ├── build │ │ ├── text.d │ │ ├── text.o │ │ ├── irq_delay.o │ │ └── irq_delay.d │ ├── irq_delay.elf │ ├── irq_delay.gba │ ├── irq_delay.sav │ └── Makefile └── timer_change │ ├── build │ ├── text.d │ ├── text.o │ ├── timer_change.o │ └── timer_change.d │ ├── timer_change.elf │ ├── timer_change.gba │ ├── timer_change.sav │ ├── source │ └── timer_change.s │ └── Makefile ├── cond_invalid ├── build │ ├── text.o │ ├── text.d │ ├── cond_invalid.o │ └── cond_invalid.d ├── cond_invalid.elf ├── cond_invalid.gba ├── cond_invalid.sav ├── source │ ├── cond_invalid.s │ └── text.s └── Makefile ├── dma_priority ├── build │ ├── dma.o │ ├── text.o │ ├── dma.d │ └── text.d ├── dma_priority.elf ├── dma_priority.gba ├── dma_priority.sav ├── Makefile └── source │ ├── dma.s │ └── text.s ├── hello_world ├── build │ ├── test.o │ ├── text.o │ ├── test.d │ └── text.d ├── hello_world.elf ├── hello_world.gba ├── hello_world.sav ├── source │ ├── test.s │ └── text.s └── Makefile ├── line_timing ├── build │ ├── text.o │ ├── text.d │ ├── line_timing.o │ └── line_timing.d ├── line_timing.elf ├── line_timing.gba ├── line_timing.sav ├── source │ ├── .line_timing.s.kate-swp │ ├── line_timing.s │ └── text.s ├── line_timing_idkwhatthisdoes.s └── Makefile ├── lyc_midline ├── build │ ├── text.o │ ├── text.d │ ├── lyc_midline.o │ └── lyc_midline.d ├── expected.jpg ├── lyc_midline.elf ├── lyc_midline.gba ├── lyc_midline.sav ├── source │ └── lyc_midline.s └── Makefile ├── window_midframe ├── build │ ├── window.o │ └── window.d ├── expected.png ├── window_midframe.elf ├── window_midframe.gba ├── window_midframe.sav ├── source │ └── window.s └── Makefile ├── LICENSE └── template └── Makefile /isr/irq_timing.sav: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gba_tests 2 | test roms for the gba 3 | -------------------------------------------------------------------------------- /isr/isr.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/isr/isr.elf -------------------------------------------------------------------------------- /isr/isr.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/isr/isr.gba -------------------------------------------------------------------------------- /isr/isr.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/isr/isr.sav -------------------------------------------------------------------------------- /isr/build/isr.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/isr/build/isr.o -------------------------------------------------------------------------------- /if_ack/if_ack.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/if_ack/if_ack.elf -------------------------------------------------------------------------------- /if_ack/if_ack.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/if_ack/if_ack.gba -------------------------------------------------------------------------------- /if_ack/if_ack.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/if_ack/if_ack.sav -------------------------------------------------------------------------------- /isr/build/isr.d: -------------------------------------------------------------------------------- 1 | isr.o: /home/destoer/projects/gba_tests/gba_tests/isr/source/isr.s 2 | -------------------------------------------------------------------------------- /isr/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/isr/build/text.o -------------------------------------------------------------------------------- /if_ack/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/if_ack/build/text.o -------------------------------------------------------------------------------- /isr/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: /home/destoer/projects/gba_tests/gba_tests/isr/source/text.s 2 | -------------------------------------------------------------------------------- /experimental/readme.md: -------------------------------------------------------------------------------- 1 | these tests are experimental i.e i dont understand the behavior they produce -------------------------------------------------------------------------------- /if_ack/build/if_ack.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/if_ack/build/if_ack.o -------------------------------------------------------------------------------- /if_ack/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: /home/regulus/projects/gba_tests/gba_tests/if_ack/source/text.s 2 | -------------------------------------------------------------------------------- /cond_invalid/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/cond_invalid/build/text.o -------------------------------------------------------------------------------- /dma_priority/build/dma.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/dma_priority/build/dma.o -------------------------------------------------------------------------------- /dma_priority/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/dma_priority/build/text.o -------------------------------------------------------------------------------- /experimental/pcmxx/build/main.d: -------------------------------------------------------------------------------- 1 | main.o: /mnt/c/projects/gba_tests/gba_tests/pcmxx/source/main.s 2 | -------------------------------------------------------------------------------- /experimental/pcmxx/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: /mnt/c/projects/gba_tests/gba_tests/pcmxx/source/text.s 2 | -------------------------------------------------------------------------------- /hello_world/build/test.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/hello_world/build/test.o -------------------------------------------------------------------------------- /hello_world/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/hello_world/build/text.o -------------------------------------------------------------------------------- /line_timing/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/line_timing/build/text.o -------------------------------------------------------------------------------- /lyc_midline/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/lyc_midline/build/text.o -------------------------------------------------------------------------------- /lyc_midline/expected.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/lyc_midline/expected.jpg -------------------------------------------------------------------------------- /experimental/joypad/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: /home/destoer/projects/gba_tests/gba_tests/joypad/source/text.s 2 | -------------------------------------------------------------------------------- /hello_world/hello_world.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/hello_world/hello_world.elf -------------------------------------------------------------------------------- /hello_world/hello_world.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/hello_world/hello_world.gba -------------------------------------------------------------------------------- /hello_world/hello_world.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/hello_world/hello_world.sav -------------------------------------------------------------------------------- /if_ack/build/if_ack.d: -------------------------------------------------------------------------------- 1 | if_ack.o: \ 2 | /home/regulus/projects/gba_tests/gba_tests/if_ack/source/if_ack.s 3 | -------------------------------------------------------------------------------- /line_timing/line_timing.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/line_timing/line_timing.elf -------------------------------------------------------------------------------- /line_timing/line_timing.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/line_timing/line_timing.gba -------------------------------------------------------------------------------- /line_timing/line_timing.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/line_timing/line_timing.sav -------------------------------------------------------------------------------- /lyc_midline/lyc_midline.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/lyc_midline/lyc_midline.elf -------------------------------------------------------------------------------- /lyc_midline/lyc_midline.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/lyc_midline/lyc_midline.gba -------------------------------------------------------------------------------- /lyc_midline/lyc_midline.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/lyc_midline/lyc_midline.sav -------------------------------------------------------------------------------- /cond_invalid/cond_invalid.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/cond_invalid/cond_invalid.elf -------------------------------------------------------------------------------- /cond_invalid/cond_invalid.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/cond_invalid/cond_invalid.gba -------------------------------------------------------------------------------- /cond_invalid/cond_invalid.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/cond_invalid/cond_invalid.sav -------------------------------------------------------------------------------- /dma_priority/build/dma.d: -------------------------------------------------------------------------------- 1 | dma.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/dma_priority/source/dma.s 3 | -------------------------------------------------------------------------------- /dma_priority/dma_priority.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/dma_priority/dma_priority.elf -------------------------------------------------------------------------------- /dma_priority/dma_priority.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/dma_priority/dma_priority.gba -------------------------------------------------------------------------------- /dma_priority/dma_priority.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/dma_priority/dma_priority.sav -------------------------------------------------------------------------------- /experimental/joypad/joypad.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/joypad/joypad.elf -------------------------------------------------------------------------------- /experimental/joypad/joypad.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/joypad/joypad.gba -------------------------------------------------------------------------------- /experimental/joypad/joypad.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/joypad/joypad.sav -------------------------------------------------------------------------------- /experimental/pcmxx/pcmxx.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/pcmxx/pcmxx.elf -------------------------------------------------------------------------------- /experimental/pcmxx/pcmxx.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/pcmxx/pcmxx.gba -------------------------------------------------------------------------------- /experimental/pcmxx/pcmxx.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/pcmxx/pcmxx.sav -------------------------------------------------------------------------------- /hello_world/build/test.d: -------------------------------------------------------------------------------- 1 | test.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/hello_world/source/test.s 3 | -------------------------------------------------------------------------------- /hello_world/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/hello_world/source/text.s 3 | -------------------------------------------------------------------------------- /line_timing/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/line_timing/source/text.s 3 | -------------------------------------------------------------------------------- /lyc_midline/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: \ 2 | /home/regulus/projects/gba_tests/gba_tests/lyc_midline/source/text.s 3 | -------------------------------------------------------------------------------- /window_midframe/build/window.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/window_midframe/build/window.o -------------------------------------------------------------------------------- /window_midframe/expected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/window_midframe/expected.png -------------------------------------------------------------------------------- /cond_invalid/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/cond_invalid/source/text.s 3 | -------------------------------------------------------------------------------- /dma_priority/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/dma_priority/source/text.s 3 | -------------------------------------------------------------------------------- /experimental/joypad/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/joypad/build/text.o -------------------------------------------------------------------------------- /experimental/pcmxx/build/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/pcmxx/build/main.o -------------------------------------------------------------------------------- /experimental/pcmxx/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/pcmxx/build/text.o -------------------------------------------------------------------------------- /line_timing/build/line_timing.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/line_timing/build/line_timing.o -------------------------------------------------------------------------------- /lyc_midline/build/lyc_midline.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/lyc_midline/build/lyc_midline.o -------------------------------------------------------------------------------- /cond_invalid/build/cond_invalid.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/cond_invalid/build/cond_invalid.o -------------------------------------------------------------------------------- /experimental/irq_delay/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/irq_delay/source/text.s 3 | -------------------------------------------------------------------------------- /experimental/irq_delay/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/irq_delay/build/text.o -------------------------------------------------------------------------------- /experimental/joypad/build/joypad.d: -------------------------------------------------------------------------------- 1 | joypad.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/joypad/source/joypad.s 3 | -------------------------------------------------------------------------------- /experimental/joypad/build/joypad.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/joypad/build/joypad.o -------------------------------------------------------------------------------- /window_midframe/window_midframe.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/window_midframe/window_midframe.elf -------------------------------------------------------------------------------- /window_midframe/window_midframe.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/window_midframe/window_midframe.gba -------------------------------------------------------------------------------- /window_midframe/window_midframe.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/window_midframe/window_midframe.sav -------------------------------------------------------------------------------- /experimental/irq_delay/irq_delay.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/irq_delay/irq_delay.elf -------------------------------------------------------------------------------- /experimental/irq_delay/irq_delay.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/irq_delay/irq_delay.gba -------------------------------------------------------------------------------- /experimental/irq_delay/irq_delay.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/irq_delay/irq_delay.sav -------------------------------------------------------------------------------- /experimental/timer_change/build/text.d: -------------------------------------------------------------------------------- 1 | text.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/timer_change/source/text.s 3 | -------------------------------------------------------------------------------- /window_midframe/build/window.d: -------------------------------------------------------------------------------- 1 | window.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/window_midframe/source/window.s 3 | -------------------------------------------------------------------------------- /experimental/irq_delay/build/irq_delay.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/irq_delay/build/irq_delay.o -------------------------------------------------------------------------------- /experimental/timer_change/build/text.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/timer_change/build/text.o -------------------------------------------------------------------------------- /line_timing/build/line_timing.d: -------------------------------------------------------------------------------- 1 | line_timing.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/line_timing/source/line_timing.s 3 | -------------------------------------------------------------------------------- /lyc_midline/build/lyc_midline.d: -------------------------------------------------------------------------------- 1 | lyc_midline.o: \ 2 | /home/regulus/projects/gba_tests/gba_tests/lyc_midline/source/lyc_midline.s 3 | -------------------------------------------------------------------------------- /cond_invalid/build/cond_invalid.d: -------------------------------------------------------------------------------- 1 | cond_invalid.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/cond_invalid/source/cond_invalid.s 3 | -------------------------------------------------------------------------------- /experimental/irq_delay/build/irq_delay.d: -------------------------------------------------------------------------------- 1 | irq_delay.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/irq_delay/source/irq_delay.s 3 | -------------------------------------------------------------------------------- /experimental/timer_change/timer_change.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/timer_change/timer_change.elf -------------------------------------------------------------------------------- /experimental/timer_change/timer_change.gba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/timer_change/timer_change.gba -------------------------------------------------------------------------------- /experimental/timer_change/timer_change.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/timer_change/timer_change.sav -------------------------------------------------------------------------------- /line_timing/source/.line_timing.s.kate-swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/line_timing/source/.line_timing.s.kate-swp -------------------------------------------------------------------------------- /experimental/timer_change/build/timer_change.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/destoer/gba_tests/HEAD/experimental/timer_change/build/timer_change.o -------------------------------------------------------------------------------- /experimental/timer_change/build/timer_change.d: -------------------------------------------------------------------------------- 1 | timer_change.o: \ 2 | /home/destoer/projects/gba_tests/gba_tests/timer_change/source/timer_change.s 3 | -------------------------------------------------------------------------------- /cond_invalid/source/cond_invalid.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | .text 4 | 5 | /* 6 | tests that instructions are not executed for the invalid arm condition code 7 | */ 8 | 9 | 10 | 11 | main: 12 | // turn off interrupts 13 | ldr r1, =#0x04000208 14 | str r1, [r1] 15 | 16 | 17 | bl init_text 18 | 19 | // iter through every value of the flags 20 | // and see what effect the invalid cond field has 21 | mov r1, #0 22 | 23 | cpsr_loop: 24 | mrs r2, cpsr 25 | and r2, #0x0fffffff 26 | mov r3, r1 27 | lsl r3, #28 28 | orr r3, r2 29 | msr cpsr, r3 30 | 31 | mov r2, #0 32 | .word 0xf3a02001 // movnv r2, #1 33 | ldr r0, =r2_string 34 | bl write 35 | mov r0, r2 36 | bl print_hex 37 | 38 | add r1, #1 39 | cmp r1, #16 40 | bne cpsr_loop 41 | 42 | infin: 43 | b infin 44 | 45 | 46 | 47 | r2_string: 48 | .asciz "\nr2 = " 49 | -------------------------------------------------------------------------------- /hello_world/source/test.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | .text 4 | 5 | /* 6 | basic test for the printing function 7 | verifys text modes are working enough to print text results 8 | */ 9 | 10 | main: 11 | // turn off interrupts 12 | ldr r1, =#0x04000208 13 | str r1, [r1] 14 | 15 | 16 | bl init_text 17 | 18 | 19 | ldr r0, =hello_world 20 | bl write 21 | bl write 22 | bl write 23 | bl write 24 | bl write 25 | bl write 26 | bl write 27 | bl write 28 | bl write 29 | bl write 30 | bl write 31 | bl write 32 | bl write 33 | bl write 34 | bl write 35 | bl write 36 | bl write 37 | bl write 38 | bl write 39 | bl write 40 | ldr r0, =it_works 41 | bl write 42 | bl write 43 | mov r0, #'b' 44 | bl putchar 45 | ldr r0, =it_works 46 | bl write 47 | bl write 48 | 49 | mov r0, sp 50 | bl print_hex 51 | 52 | infin: 53 | b infin 54 | 55 | 56 | .data 57 | hello_world: 58 | .asciz "hello world!\n" 59 | 60 | it_works: 61 | .asciz "it works\n" -------------------------------------------------------------------------------- /if_ack/source/if_ack.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | .text 4 | 5 | /* 6 | checks the intr are acknowledged by writing a '1' bit to it 7 | */ 8 | 9 | main: 10 | // turn off interrupts 11 | ldr r1, =#0x04000208 12 | strb r1, [r1] 13 | 14 | bl init_text 15 | 16 | ldr r2, =#0x04000004 17 | ldr r1, =#0x04000202 18 | 19 | // enable vblank intr 20 | ldrh r3, [r2] 21 | orr r3, #8 22 | strh r3, [r2] 23 | 24 | // wait for a vblank intr 25 | vblank_wait: 26 | ldrh r3, [r1] 27 | and r3, #1 28 | cmp r3, #1 29 | bne vblank_wait 30 | 31 | // acknowlege it by writing '1' to the if reg 32 | mov r4, #0xffffffff 33 | strh r4, [r1] 34 | 35 | ldrh r4, [r1] 36 | 37 | ldr r0, =string 38 | bl write 39 | 40 | mov r0, r3 41 | bl print_hex 42 | 43 | mov r0, #0xa 44 | bl putchar 45 | 46 | mov r0, r4 47 | bl print_hex 48 | 49 | 50 | infin: 51 | b infin 52 | 53 | .data 54 | 55 | string: 56 | .asciz "if vblank acknowledge\n" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Michael Loftus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /experimental/timer_change/source/timer_change.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | .text 4 | 5 | 6 | /* 7 | tests changing timer settings while it is running 8 | no idea why certain results are gotten yet 9 | */ 10 | 11 | 12 | reset_timer: 13 | push {r0,r1} 14 | 15 | ldr r0, =#0x04000100 16 | mov r1, #0 17 | strh r1, [r0] 18 | strh r1, [r0,#2] 19 | mov r1, #0x83 20 | // enable the timer 21 | strh r1, [r0,#2] 22 | 23 | pop {r0,r1} 24 | bx lr 25 | 26 | main: 27 | // turn off interrupts 28 | ldr r1, =#0x04000208 29 | str r1, [r1] 30 | 31 | 32 | bl init_text 33 | 34 | bl reset_timer 35 | 36 | 37 | // okay now we delay a bunch 38 | // get a good number of cycles 39 | // then we simply switch the tick mode and read out the timer 40 | 41 | mov r0, #100 42 | 43 | wait_loop: 44 | subs r0, #1 45 | bne wait_loop 46 | 47 | //pull timer 48 | ldr r1, =#0x04000100 49 | ldrh r2, [r1] 50 | 51 | bl reset_timer 52 | 53 | 54 | // okay now mess with the prescaler 55 | mov r0, #0x80 56 | strh r0, [r1,#2] 57 | 58 | ldrh r3, [r1] 59 | 60 | // print results 61 | mov r0, r2 62 | bl print_hex 63 | ldr r0, =new_line 64 | bl write 65 | mov r0, r3 66 | bl print_hex 67 | 68 | 69 | bl reset_timer 70 | 71 | // now for jokes lets flash the timer on and off 72 | // okay now mess with the prescaler 73 | mov r0, #0x80 74 | mov r2, #0 75 | mov r3, #10 76 | rapid_loop: 77 | strh r0, [r1,#2] 78 | strh r2, [r1,#2] 79 | subs r3, #1 80 | bne rapid_loop 81 | 82 | ldr r0, =new_line 83 | bl write 84 | ldrh r0, [r1] 85 | bl print_hex 86 | 87 | infin: 88 | b infin 89 | 90 | new_line: 91 | .asciz "\n" 92 | -------------------------------------------------------------------------------- /experimental/pcmxx/source/main.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | .text 4 | 5 | 6 | // init wave ram to a value and look for that nibble somewhere in the io range 7 | // to see if there is an eqiv of pcmxx for the gba that LIJI found on the gb 8 | 9 | // TODO: 10 | // check if there is an eqiv for the dma sound 11 | // if there is a pcmxx in gba moade i cant find it 12 | 13 | // thanks 14 | // https://github.com/LIJI32/ 15 | // 16 | // <^) 17 | // (__)> 18 | 19 | init_wave_ram: 20 | push {r0-r3} 21 | // memset wave ram to 0xaa 22 | ldr r0, =#0x04000090 23 | ldr r1, =#0x040000A0 24 | ldr r2, =#0xaa 25 | //mov r2, #0x0 26 | memset_wave_ram: 27 | strb r2, [r0] 28 | //add r2, #0x15 29 | add r0, #1 30 | cmp r0, r1 31 | bne memset_wave_ram 32 | pop {r0-r3} 33 | bx lr 34 | 35 | main: 36 | // turn off interrupts 37 | ldr r1, =#0x04000208 38 | str r1, [r1] 39 | 40 | 41 | bl init_text 42 | 43 | ldr r0, =setup 44 | bl write 45 | 46 | 47 | // enable nr52 master 48 | ldr r0, =#0x04000084 49 | mov r1, #0xffffffff 50 | str r1, [r0] 51 | 52 | // psg max all others off 53 | ldr r0, =#0x04000082 54 | mov r1, #0x2 55 | strh r1, [r0] 56 | 57 | // turn off dac & fill both banks 58 | mov r1, #0x20 59 | ldr r0, =#0x04000070 60 | strh r1, [r0] 61 | 62 | bl init_wave_ram 63 | 64 | mov r1, #0x60 65 | ldr r0, =#0x04000070 66 | strh r1, [r0] 67 | 68 | bl init_wave_ram 69 | 70 | // enable everything in nr50 & 51 71 | ldr r0, =#0x04000080 72 | mov r1, #0xffffffff 73 | strh r1, [r0] 74 | 75 | // turn on dac 76 | mov r1, #0xff 77 | ldr r0, =#0x04000070 78 | strh r1, [r0] 79 | 80 | // max sample 81 | mov r1, #0xffffffff 82 | ldr r0, =#0x04000088 83 | strh r1, [r0] 84 | 85 | 86 | // max vol + len 87 | ldr r1, =#0x2000 88 | ldr r0, =#0x04000072 89 | strh r1, [r0] 90 | 91 | // now just start the wave chan 92 | ldr r1, =#0x8000 93 | ldr r0, =#0x04000074 94 | strh r1, [r0] 95 | 96 | 97 | ldr r0, =tone 98 | bl write 99 | 100 | 101 | scan_loop: 102 | ldr r4, =#0x04000000 103 | ldr r1, =#0x04000800 104 | 105 | ldr r5, =#0x04000090 106 | ldr r6, =#0x040000A0 107 | 108 | # scan for pcmxx 109 | scan_pcm: 110 | 111 | # ignore wave ram it will ofc course have our sample! 112 | cmp r4, r5 113 | bge wave_ram_range_2nd 114 | b scan_main 115 | 116 | 117 | wave_ram_range_2nd: 118 | cmp r4, r6 119 | ble scan_pcm_end 120 | 121 | scan_main: 122 | ldrb r2, [r4] 123 | nop 124 | and r3,r2, #0xf 125 | cmp r3, #0xa 126 | 127 | bne scan_pcm_high 128 | mov r0, r4 129 | bl print_hex 130 | ldr r0, =newline 131 | bl write 132 | b scan_pcm_end 133 | 134 | scan_pcm_high: 135 | and r3,r2, #0xf0 136 | cmp r3, #0xaa 137 | bne scan_pcm_end 138 | 139 | mov r0, r4 140 | bl print_hex 141 | ldr r0, =newline 142 | bl write 143 | b scan_pcm_end 144 | 145 | scan_pcm_end: 146 | add r4, #1 147 | cmp r4, r1 148 | bne scan_pcm 149 | 150 | 151 | b scan_loop 152 | 153 | ldr r0, =end 154 | bl write 155 | 156 | infin: 157 | b infin 158 | 159 | setup: 160 | .asciz "setting up wave chan\n" 161 | 162 | tone: 163 | .asciz "playing tone\n" 164 | 165 | end: 166 | .asciz "scan end\n" 167 | 168 | newline: 169 | .asciz "\n" -------------------------------------------------------------------------------- /line_timing/source/line_timing.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .global main 4 | .arm 5 | .text 6 | 7 | 8 | /* 9 | tests basic line timings 10 | 11 | */ 12 | 13 | 14 | // wait for vcount to sync line then wait for hblank 15 | wait_intr: 16 | push {r0-r3,lr} 17 | mov r3, r2 18 | 19 | // store 40 into vcount compare 20 | //ldr r0, =#0x04000005 21 | //ldrb r1, [r0,#1] 22 | mov r1, #40 23 | strb r1, [r0] 24 | 25 | mov r2, #0x02000000 26 | add r2, #0x400 27 | 28 | // reset our intr source 29 | mov r0, #0 30 | str r0, [r2] 31 | 32 | 33 | // set ie mask to allow vcount 34 | ldr r0, =#0x04000202 35 | mov r1, #0xffffffff 36 | strh r1, [r0] 37 | ldr r0, =#0x04000200 38 | mov r1, #4 39 | strh r1, [r0] 40 | 41 | 42 | // setup timer 0 to count the intr time 43 | ldr r0, =#0x04000100 44 | mov r1, #0 45 | strh r1, [r0] 46 | strh r1, [r0,#2] 47 | mov r1, #0x80 48 | 49 | // halt 50 | swi #0x020000 51 | 52 | 53 | // enable the timer 54 | strh r1, [r0,#2] 55 | 56 | // set ie mask to allow hblank 57 | ldr r0, =#0x04000202 58 | mov r1, #0xffffffff 59 | strh r1, [r0] 60 | ldr r0, =#0x04000200 61 | mov r1, #2 62 | strh r1, [r0] 63 | 64 | 65 | //pull timer 66 | ldr r1, =#0x04000100 67 | 68 | // halt 69 | swi #0x020000 70 | 71 | 72 | ldrh r3, [r1] 73 | 74 | // dump some vars 75 | ldr r1, =#0x02000400 76 | str r3, [r1] 77 | 78 | 79 | pop {r0-r3,lr} 80 | bx lr 81 | 82 | 83 | main: 84 | // turn off interrupts 85 | ldr r1, =#0x04000208 86 | str r1, [r1] 87 | 88 | // turn off prefetch buffer 89 | // and max sram wait state 90 | ldr r1, =#0x04000204 91 | mov r0, #3 92 | str r0, [r1] 93 | 94 | bl init_text 95 | 96 | // enable the hblank intr and vcount intr 97 | ldr r1, =#0x04000004 98 | mov r0, #48 99 | strh r0, [r1] 100 | 101 | 102 | /* 103 | // dispcnt enable all bg text mode 0 104 | mov r0, #0x04000000 105 | mov r1, #0xF00 106 | strh r1, [r0] 107 | */ 108 | ldr r1, =#0x04000010 109 | ldr r3, =#0x02000400 110 | ldr r5, =#0x02000600 111 | mov r2, #0 112 | 113 | intr_loop: 114 | strh r2, [r1] 115 | strh r2, [r1,#4] 116 | strh r2, [r1,#8] 117 | strh r2, [r1,#12] 118 | 119 | bl wait_intr 120 | 121 | 122 | // print scx 123 | ldr r0, =newline_string 124 | bl write 125 | mov r0, r2 126 | bl print_hex 127 | 128 | // print timer 129 | ldr r0, =seperator_string 130 | bl write 131 | 132 | ldr r0, [r3] 133 | bl print_hex 134 | 135 | 136 | str r0, [r5] 137 | add r5, #4 138 | 139 | add r2, #1 140 | cmp r2, #512 141 | bne intr_loop 142 | 143 | 144 | 145 | mov r2, #0 146 | ldr r5, =#0x02000600 147 | sram_dump: 148 | 149 | // ok now lets try write the result to sram 150 | ldr r1, =0x0e000000 151 | add r1, r2, lsl #2 152 | 153 | // write a byte 154 | ldr r0, [r5] 155 | and r4, r0, #0xff 156 | lsr r0, #8 157 | strb r4, [r1,#0] 158 | 159 | // write a byte 160 | and r4, r0, #0xff 161 | lsr r0, #8 162 | strb r4, [r1,#1] 163 | 164 | // write a byte 165 | and r4, r0, #0xff 166 | lsr r0, #8 167 | strb r4, [r1,#2] 168 | 169 | // write a byte 170 | and r4, r0, #0xff 171 | lsr r0, #8 172 | strb r4, [r1,#3] 173 | 174 | add r5, #4 175 | add r2, #1 176 | cmp r2, #512 177 | bne sram_dump 178 | 179 | ldr r0, =sram_write 180 | bl write 181 | infin: 182 | b infin 183 | 184 | 185 | 186 | 187 | .data 188 | 189 | 190 | 191 | 192 | newline_string: 193 | .asciz "\n " 194 | seperator_string: 195 | .asciz " : " 196 | 197 | sram_write: 198 | .asciz "\nsram write done" 199 | 200 | // trick cart detection into using sram 201 | sram_string: 202 | .asciz "SRAM_" 203 | -------------------------------------------------------------------------------- /lyc_midline/source/lyc_midline.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | .text 4 | 5 | // register defines 6 | .equ IME, 0x04000208 7 | .equ IF, 0x04000202 8 | .equ DISP_STAT, 0x04000004 9 | .equ LYC, 0x04000005 10 | .equ VCOUNT, 0x04000006 11 | .equ TM0CNT_L, 0x04000100 12 | 13 | // sync to visible on line 0x10 14 | line_sync: 15 | push {r0-r2} 16 | ldr r1, =DISP_STAT 17 | ldr r0, =VCOUNT 18 | wait: 19 | ldrh r2, [r1] 20 | ands r2, #3 21 | bne wait 22 | ldrb r2, [r0] 23 | cmp r2, r2 24 | bne wait 25 | 26 | pop {r0-r2} 27 | bx lr 28 | 29 | 30 | /* 31 | tests what happens during midline lyc writes 32 | 33 | */ 34 | 35 | 36 | main: 37 | 38 | // turn off interrupts 39 | ldr r1, =IME 40 | str r1, [r1] 41 | 42 | // acklowedge all interrupts 43 | mov r0, #0xffffffff 44 | ldr r1, =IF 45 | strh r0, [r1] 46 | 47 | // set lyc to something too high 48 | // so it wont trigger 49 | ldr r4, =LYC 50 | strb r0, [r4] 51 | 52 | 53 | 54 | // enable vcount interrupt 55 | ldr r0, =DISP_STAT 56 | ldrb r1, [r0] 57 | orr r1, #0x20 58 | strb r1, [r0] 59 | 60 | bl line_sync 61 | 62 | // setup the timers 63 | ldr r0, =TM0CNT_L 64 | mov r1, #0 65 | strh r1, [r0] 66 | strh r1, [r0,#2] 67 | mov r1, #0x80 68 | strh r1, [r0,#2] 69 | 70 | // pull start 71 | ldrh r3, [r0] 72 | 73 | ldr r1, =DISP_STAT 74 | 75 | // set vcount to lyc 76 | ldrb r2, [r1,#2] 77 | strb r2, [r1,#1] 78 | 79 | // get result 80 | ldrb r2, [r1] 81 | 82 | // get end 83 | ldrh r5, [r0] 84 | 85 | 86 | bl init_text 87 | 88 | // print our first load of writes 89 | 90 | ldr r0, =start_string 91 | bl write 92 | mov r0, r3 93 | bl print_hex 94 | 95 | ldr r0, =end_string 96 | bl write 97 | mov r0, r5 98 | bl print_hex 99 | 100 | ldr r0, =vcount_string 101 | bl write 102 | mov r0, r2 103 | bl print_hex 104 | 105 | ldr r0, =rapid_string 106 | bl write 107 | 108 | 109 | 110 | 111 | ldr r0, =DISP_STAT 112 | 113 | mov r3, #0xffffffff 114 | 115 | // if lyc == vcount set it to something nonsense 116 | strb r3, [r0,#1] 117 | 118 | ldr r7, =IF 119 | // acknowledge the intr 120 | strh r3, [r7] 121 | 122 | bl line_sync 123 | 124 | // cache ly 125 | ldrb r1, [r0,#2] 126 | mov r4, #0 127 | 128 | ldr r2, =TM0CNT_L 129 | // get start 130 | ldrh r5, [r2] 131 | 132 | 133 | 134 | // while our initial ly is the current line 135 | // keep writing matching and non matching lyc values 136 | // and see how many times the intr fires 137 | rapid_loop: 138 | 139 | 140 | ldrb r2, [r7] 141 | and r2, #4 142 | cmp r2, #4 143 | beq set_lyc_invalid 144 | 145 | 146 | // set lyc = ly 147 | // and trigger an interrupt req 148 | strb r1, [r0,#1] 149 | 150 | b rapid_check 151 | 152 | set_lyc_invalid: 153 | // if lyc == vcount set it to something nonsense 154 | strb r3, [r0,#1] 155 | 156 | // acknowledge the intr 157 | strh r3, [r7] 158 | 159 | add r4, #1 160 | 161 | 162 | 163 | rapid_check: 164 | ldrb r2, [r0,#2] 165 | cmp r1, r2 166 | beq rapid_loop 167 | 168 | 169 | // get end 170 | ldr r2, =TM0CNT_L 171 | ldrh r6, [r2] 172 | 173 | 174 | 175 | // print our results 176 | 177 | ldr r0, =start_string 178 | bl write 179 | mov r0, r5 180 | bl print_hex 181 | 182 | ldr r0, =end_string 183 | bl write 184 | mov r0, r6 185 | bl print_hex 186 | 187 | ldr r0, =count_string 188 | bl write 189 | mov r0, r4 190 | bl print_hex 191 | 192 | 193 | infin: 194 | b infin 195 | 196 | .data 197 | 198 | vcount_string: 199 | .asciz "\nvcount: " 200 | 201 | start_string: 202 | .asciz "\nstart: " 203 | 204 | end_string: 205 | .asciz "\nend: " 206 | 207 | rapid_string: 208 | .asciz "\n\nrapid toggle\n\n" 209 | 210 | count_string: 211 | .asciz "\nlyc count: " -------------------------------------------------------------------------------- /line_timing/line_timing_idkwhatthisdoes.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | .global main 4 | .arm 5 | .text 6 | 7 | // prints timings on hardware that i dont understand 8 | // this test is buggy... 9 | 10 | isr: 11 | 12 | //pull timer 13 | mov r1, #0x04000000 14 | add r1, #0x100 15 | 16 | ldrh r3, [r1] 17 | 18 | // ackknowledge intr 19 | add r1, #0x100 20 | add r1, #2 21 | 22 | // pull it first 23 | ldrh r2, [r1] 24 | 25 | mov r0, #0xffffffff 26 | strh r0, [r1] 27 | 28 | // dump some vars 29 | mov r8, #0x02000000 30 | add r8, #0x400 31 | 32 | 33 | 34 | // check what intr we got 35 | 36 | // got a hblank intr 37 | and r1, r2, #2 38 | cmp r1, #2 39 | beq hblank 40 | 41 | // got a vcount intr 42 | and r1, r2, #4 43 | cmp r1, #4 44 | beq vcount 45 | 46 | // dont know rofl 47 | b other 48 | 49 | hblank: 50 | mov r1, #1 51 | b source_done 52 | 53 | vcount: 54 | mov r1, #2 55 | b source_done 56 | 57 | other: 58 | mov r1, #3 59 | 60 | source_done: 61 | str r1, [r8] 62 | 63 | 64 | // store the time for it to fire 65 | str r3, [r8, #4] 66 | 67 | mov r7, lr 68 | 69 | // store the lr pushed to return to the mode intr was called from 70 | // the bios after calling our handler wille execute this instr 71 | // with a stack writeback 72 | ldmfd r13, {r0-r3,r12,r14} 73 | 74 | str lr, [r8, #8] 75 | 76 | mov lr, r7 77 | bx lr 78 | 79 | 80 | isr_end: 81 | 82 | isr_size = isr_end - isr 83 | 84 | 85 | // wait for vcount to sync line then wait for hblank 86 | wait_intr: 87 | push {r0-r3,lr} 88 | 89 | 90 | // store vcount-1 into vcount compare 91 | ldr r0, =#04000005 92 | ldrb r1, [r0,#1] 93 | sub r1, #1 94 | strb r1, [r0] 95 | 96 | 97 | /* 98 | // store 40 into vcount 99 | ldr r0, =#04000005 100 | mov r1, #40 101 | strb r1, [r0] 102 | */ 103 | mov r2, #0x02000000 104 | add r2, #0x400 105 | 106 | // reset our intr source 107 | mov r0, #0 108 | str r0, [r2] 109 | 110 | 111 | // set ie mask to allow vcount 112 | ldr r0, =#0x04000200 113 | mov r1, #4 114 | strh r1, [r0] 115 | 116 | // halt 117 | swi #0x020000 118 | 119 | 120 | // setup timer 0 to count the intr time 121 | ldr r0, =#0x04000100 122 | mov r1, #0 123 | strh r1, [r0] 124 | strh r1, [r0,#2] 125 | mov r1, #0x80 126 | strh r1, [r0,#2] 127 | 128 | 129 | // set ie mask to allow hblank 130 | ldr r0, =#0x04000200 131 | mov r1, #2 132 | strh r1, [r0] 133 | 134 | // halt 135 | swi #0x020000 136 | 137 | pop {r0-r3,lr} 138 | bx lr 139 | 140 | 141 | main: 142 | // turn off interrupts 143 | ldr r1, =#0x04000208 144 | str r1, [r1] 145 | 146 | // turn off prefetch buffer 147 | // and max sram wait state 148 | ldr r1, =#0x04000204 149 | mov r0, #3 150 | str r0, [r1] 151 | 152 | bl init_text 153 | 154 | // copy our isr to wram 155 | ldr r0, =#0x03000400 156 | ldr r1, =isr 157 | ldr r2, =isr_size 158 | 159 | bl memcpy 160 | 161 | // setup our isr pointer 162 | ldr r0, =#0x03007FFC 163 | ldr r1, =#0x03000400 164 | str r1,[r0] 165 | 166 | // enable interrupt servicing 167 | ldr r1, =#0x04000208 168 | mov r0, #1 169 | str r0, [r1] 170 | 171 | // enable the hblank intr and vcount intr 172 | ldr r1, =#0x04000004 173 | mov r0, #48 174 | strh r0, [r1] 175 | 176 | 177 | 178 | // dispcnt enable all bg text mode 0 179 | mov r0, #0x04000000 180 | mov r1, #0xF00 181 | strh r1, [r0] 182 | 183 | ldr r1, =#0x04000010 184 | //ldr r1, =#0x04000014 185 | ldr r3, =#0x02000400 186 | ldr r5, =#0x02000600 187 | /* 188 | bl wait_intr 189 | bl wait_intr 190 | bl wait_intr 191 | bl wait_intr 192 | bl wait_intr 193 | bl wait_intr 194 | */ 195 | 196 | intr_loop: 197 | strh r2, [r1] 198 | strh r2, [r1,#4] 199 | strh r2, [r1,#8] 200 | strh r2, [r1,#12] 201 | bl wait_intr 202 | 203 | 204 | // print scx 205 | ldr r0, =newline_string 206 | bl write 207 | mov r0, r2 208 | bl print_hex 209 | 210 | // print timer 211 | ldr r0, =seperator_string 212 | bl write 213 | 214 | ldr r0, [r3,#4] 215 | bl print_hex 216 | 217 | 218 | str r0, [r5] 219 | add r5, #4 220 | 221 | add r2, #1 222 | cmp r2, #512 223 | bne intr_loop 224 | 225 | 226 | 227 | mov r2, #0 228 | ldr r5, =#0x02000600 229 | sram_dump: 230 | 231 | // ok now lets try write the result to sram 232 | ldr r1, =0x0e000000 233 | add r1, r2, lsl #2 234 | 235 | // write a byte 236 | ldr r0, [r5] 237 | and r4, r0, #0xff 238 | lsr r0, #8 239 | strb r4, [r1,#0] 240 | 241 | // write a byte 242 | and r4, r0, #0xff 243 | lsr r0, #8 244 | strb r4, [r1,#1] 245 | 246 | // write a byte 247 | and r4, r0, #0xff 248 | lsr r0, #8 249 | strb r4, [r1,#2] 250 | 251 | // write a byte 252 | and r4, r0, #0xff 253 | lsr r0, #8 254 | strb r4, [r1,#3] 255 | 256 | add r5, #4 257 | add r2, #1 258 | cmp r2, #512 259 | bne sram_dump 260 | 261 | ldr r0, =sram_write 262 | bl write 263 | infin: 264 | b infin 265 | 266 | 267 | 268 | 269 | .data 270 | 271 | 272 | 273 | 274 | newline_string: 275 | .asciz "\n " 276 | seperator_string: 277 | .asciz " : " 278 | 279 | sram_write: 280 | .asciz "\nsram write done" 281 | 282 | // trick cart detection into using sram 283 | sram_string: 284 | .asciz "SRAM_" 285 | -------------------------------------------------------------------------------- /window_midframe/source/window.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | 4 | 5 | /* 6 | tests window behavior in the middle of a frame, 7 | how i supsect the hardware works is that win1 & win0 have an internal flag 8 | that enables the window 9 | 10 | when it hits y1 it is enabled 11 | when it hits y2 it is disabled 12 | this is reaserted on every line even vblank 13 | 14 | this explains why setting wy lower than the current line but not directly hitting it 15 | will cause the window to not draw 16 | 17 | it also explains this line in gbatek 18 | https://problemkaputt.de/gbatek.htm 19 | "Y1>Y2 are interpreted as Y2=160" 20 | 21 | because the disable is hit first it will not get turned off again until it wraps back around and hits it 22 | gbatek also seems wrong slightly wrong in this regard and said checks are still asserted in vblank 23 | likely this is when the ly changes but im not sure 24 | 25 | as can be seen in tonc win_demo 26 | https://www.coranac.com/tonc/text/gfx.htm#sec-win 27 | 28 | moving window off the top and bottom of the screen 29 | the y2=160 would make you think the flag is reset at vblank but it does not appear to be the case 30 | 31 | thanks fleroviux for testing this in nba =) 32 | https://github.com/fleroviux/NanoboyAdvance/ 33 | 34 | also thanks to powerlated for the expected screenshot 35 | https://github.com/Powerlated 36 | */ 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | // param r1 line 45 | // waits for specified line by waiting for line start 46 | // and then for hblank 47 | // with swi halt 48 | wait_line: 49 | push {r0-r1} 50 | 51 | // store vcount compare with r1 52 | ldr r0, =#0x04000005 53 | strb r1, [r0] 54 | 55 | // enable vcount 56 | ldr r0, =#0x04000200 57 | mov r1, #4 58 | strh r1, [r0] 59 | 60 | // halt 61 | swi #0x020000 62 | ldr r0, =#0x04000202 63 | mov r1, #0xffffffff 64 | strh r1, [r0] 65 | 66 | 67 | // ok now we wait for hblank 68 | ldr r0, =#0x04000200 69 | mov r1, #2 70 | strh r1, [r0] 71 | 72 | // halt 73 | swi #0x020000 74 | ldr r0, =#0x04000202 75 | mov r1, #0xffffffff 76 | strh r1, [r0] 77 | 78 | pop {r0-r1} 79 | bx lr 80 | 81 | 82 | // param r1 wy min 83 | // sets wy0 y1 to param 84 | set_wy0_min: 85 | push {r0-r1} 86 | 87 | // ok now set wy0 min to 70 88 | ldr r0, =#0x04000044 89 | strb r1, [r0,#1] 90 | 91 | pop {r0-r1} 92 | bx lr 93 | 94 | // param r1 wy max 95 | // sets wy0 y2 to param 96 | set_wy0_max: 97 | push {r0-r1} 98 | 99 | ldr r0, =#0x4000044 100 | strb r1, [r0] 101 | 102 | pop {r0-r1} 103 | bx lr 104 | 105 | main: 106 | // turn off interrupts 107 | mov r0, #0 108 | ldr r1, =#0x04000208 109 | str r0, [r1] 110 | 111 | 112 | 113 | // enable the hblank intr and vcount intr 114 | ldr r1, =#0x04000004 115 | mov r0, #48 116 | strh r0, [r1] 117 | 118 | 119 | 120 | 121 | // ok red screen gang time 122 | 123 | mov r0, #0x04000000 // dispcnt 124 | ldr r1, =#0x2403 // window 0 on 125 | strh r1, [r0] 126 | 127 | 128 | //memcpy red into vram :P 129 | mov r0, #0x06000000 130 | mov r1, #0 131 | ldr r2, =#0x06012c00 132 | 133 | vram_loop: 134 | strh r1, [r0] 135 | add r1, #10 136 | add r0, #2 137 | cmp r2, r0 138 | bne vram_loop 139 | 140 | 141 | 142 | // winout enable everything 143 | ldr r1, =#0x0400004a 144 | mov r2, #0xffffffff 145 | strh r2, [r1] 146 | 147 | // win zero setup 148 | # max wx conver entire scren 149 | ldr r1, =#0x4000040 150 | mov r2, #0 151 | strb r2, [r1,#1] 152 | mov r2, #241 153 | strb r2, [r1] 154 | 155 | # end of screen cover 156 | ldr r1, =#0x04000044 157 | mov r2, #141 158 | strb r2, [r1] 159 | 160 | 161 | 162 | // win 1 setup 163 | # max wx conver entire scren 164 | ldr r1, =#0x4000042 165 | mov r2, #0 166 | strb r2, [r1,#1] 167 | mov r2, #241 168 | strb r2, [r1] 169 | 170 | // we aernt going to change this i just want something to make sure the windows 171 | // are otherwhise behaving fine 172 | // so put something at the top of the screen out of the way of where we are testing 173 | // 10 - 40 174 | ldr r1, =#0x04000046 175 | mov r2, #10 176 | strb r2, [r1,#1] 177 | mov r2, #41 178 | strb r2, [r1] 179 | 180 | 181 | // set ie mask to allow vcount 182 | ldr r0, =#0x04000202 183 | mov r1, #0xffffffff 184 | strh r1, [r0] 185 | ldr r0, =#0x04000200 186 | mov r1, #2 187 | strh r1, [r0] 188 | 189 | mov r0, #0x04000000 // dispcnt 190 | ldr r1, =#0x6403 // window 0 & 1 on 191 | strh r1, [r0] 192 | 193 | 194 | // todo how does the object window work? 195 | 196 | window_loop: 197 | 198 | // now we have a red screen setup the window to turn off the bg 199 | // when we do the all important wy write 200 | 201 | // todo fiddle the window turn off 202 | 203 | // wait 160 204 | mov r1, #160 205 | bl wait_line 206 | 207 | // test that it reasserts the check in vblank 208 | mov r1, #161 209 | bl set_wy0_min 210 | 211 | mov r1, #5 212 | bl set_wy0_max 213 | bl wait_line 214 | 215 | 216 | 217 | mov r1, #141 218 | bl set_wy0_max 219 | 220 | 221 | // no window max = min 222 | // wy0 = 140 223 | mov r1, #140 224 | bl set_wy0_min 225 | 226 | 227 | // in theory it is asserted on line start and a internal flag set 228 | // so if we dont this it not going to be active 229 | // i.e its not doing >= 230 | // wait 80 231 | mov r1, #80 232 | bl wait_line 233 | 234 | // wy0 = 70 235 | mov r1, #70 236 | bl set_wy0_min 237 | 238 | 239 | // from here is new 240 | 241 | // test draw 80-100 242 | // wait 100 243 | mov r1, #100 244 | bl wait_line 245 | 246 | // test if triggering it all gives free reign for rest of screen time 247 | mov r1, #101 248 | bl set_wy0_min 249 | bl wait_line 250 | 251 | // test 101-110 252 | mov r1, #110 253 | bl set_wy0_min 254 | bl wait_line 255 | 256 | // no window max = min 257 | mov r1, #140 258 | bl set_wy0_min 259 | 260 | b window_loop 261 | 262 | 263 | infin: 264 | b infin 265 | -------------------------------------------------------------------------------- /experimental/joypad/source/joypad.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | .text 4 | /* 5 | checks the joypad and joypad control regs 6 | requires interrupts 7 | 8 | do not understand the results on hardware 9 | they do not line up with how the regs are documented 10 | */ 11 | 12 | 13 | // wait until the joypad reg gives the button state we expect 14 | // args r0: expected button state 15 | button_wait: 16 | push {r0-r5} 17 | // only interested in the button bits 18 | ldr r2, =#0x3ff 19 | and r0, r2 20 | ldr r1, =#0x04000130 21 | ldr r3, =#0x04000202 22 | wait: 23 | // acknowledge our intrs 24 | // this is in case users push the wrong button while waiting 25 | mov r5, #0xffffffff 26 | strh r5, [r3] 27 | 28 | ldrh r2, [r1] 29 | cmp r0, r2 30 | bne wait 31 | 32 | pop {r0-r5} 33 | bx lr 34 | 35 | main: 36 | // turn off interrupts 37 | ldr r1, =#0x04000208 38 | strb r1, [r1] 39 | 40 | // acknowledge our intrs 41 | ldr r3, =#0x04000202 42 | mov r5, #0xffffffff 43 | strh r5, [r3] 44 | 45 | bl init_text 46 | 47 | 48 | ldr r0, =unpressed_high_string 49 | bl write 50 | 51 | // check that the joypad register has bits '1' 52 | // for unpressed buttons 53 | // this will provide inaccurate results if users 54 | // hold buttons while the test boots 55 | // but theres not much to be done about this 56 | ldr r1, =#0x04000130 57 | ldrh r0, [r1] 58 | 59 | ldr r2, =#0x3ff 60 | cmp r0, r2 61 | bne fail_keyinput 62 | 63 | ldr r0, =ok_string 64 | 65 | b print_keyinput 66 | 67 | fail_keyinput: 68 | ldr r0, =fail_string 69 | 70 | print_keyinput: 71 | bl write 72 | 73 | 74 | ldr r0, =and_string 75 | bl write 76 | 77 | ldr r3, =#0x04000202 78 | ldr r4, =#0x04000132 79 | 80 | // check keycnt and mode intr fires with no buttons pressed 81 | // fails on real hardware and i cant figure out why!? 82 | 83 | ldr r0, =and_no_select 84 | bl write 85 | 86 | mvn r0, #0 87 | bl button_wait 88 | 89 | mov r5, #0 90 | strh r5, [r4] 91 | 92 | mvn r0, #0 93 | bl button_wait 94 | 95 | // set to and mode and enable intr 96 | mov r5, #192 97 | strb r5, [r4,#1] 98 | 99 | 100 | // check intr fired 101 | ldrh r5, [r3] 102 | and r5, #4096 103 | cmp r5, #4096 104 | 105 | bne and_fail 106 | 107 | ldr r0, =ok_string 108 | 109 | b print_and_no_select 110 | and_fail: 111 | 112 | ldr r0, =fail_string 113 | 114 | print_and_no_select: 115 | bl write 116 | 117 | 118 | ldr r0, =press_a_and_b 119 | bl write 120 | 121 | ldr r0, =and_select 122 | bl write 123 | 124 | // check keycnt and mode intr fires with both buttons pressed 125 | 126 | // wait for no input 127 | mvn r0, #0 128 | bl button_wait 129 | 130 | // filter by 'A' and 'B' 131 | mov r5, #3 132 | strb r5, [r4] 133 | 134 | mvn r0, #0 135 | bl button_wait 136 | 137 | // a and b down 138 | mvn r0, #3 139 | bl button_wait 140 | 141 | // check intr fired 142 | ldrh r5, [r3] 143 | and r5, #4096 144 | cmp r5, #4096 145 | 146 | bne fail_and_select 147 | 148 | ldr r0, =ok_string 149 | 150 | b and_select_print 151 | 152 | fail_and_select: 153 | ldr r0, =fail_string 154 | 155 | and_select_print: 156 | bl write 157 | 158 | 159 | ldr r0, =press_a 160 | bl write 161 | 162 | // check no intr fires when the selected and buttons aernt pressed 163 | // hardware wants 'a' and 'b' for one to fire still 164 | ldr r0, =and_no_intr 165 | bl write 166 | 167 | mvn r0, #0 168 | bl button_wait 169 | 170 | // wait for a press 171 | mvn r0, #1 172 | bl button_wait 173 | 174 | 175 | // check no intr fired 176 | ldrh r5, [r3] 177 | and r5, #4096 178 | cmp r5, #4096 179 | 180 | beq and_no_intr_fail 181 | 182 | ldr r0, =ok_string 183 | 184 | b and_no_intr_print 185 | 186 | and_no_intr_fail: 187 | ldr r0, =fail_string 188 | 189 | and_no_intr_print: 190 | bl write 191 | 192 | 193 | ldr r0, =press_a_and_b 194 | bl write 195 | 196 | ldr r0, =and_no_irq 197 | bl write 198 | 199 | 200 | mvn r0, #0 201 | bl button_wait 202 | 203 | // test that an intr does not fire when the irq is off 204 | 205 | // set to and mode no enable intr 206 | mov r5, #128 207 | strb r5, [r4,#1] 208 | 209 | mvn r0, #0 210 | bl button_wait 211 | 212 | mvn r0, #3 213 | bl button_wait 214 | 215 | // check no intr fired 216 | ldrh r5, [r3] 217 | and r5, #4096 218 | cmp r5, #4096 219 | beq and_no_irq_fail 220 | 221 | ldr r0, =ok_string 222 | 223 | b and_no_irq_print 224 | 225 | and_no_irq_fail: 226 | ldr r0, =fail_string 227 | 228 | and_no_irq_print: 229 | bl write 230 | 231 | 232 | ldr r0, =or_string 233 | bl write 234 | 235 | 236 | ldr r0, =press_a 237 | bl write 238 | 239 | 240 | ldr r0, =or_select 241 | bl write 242 | 243 | // check or mode fires when the specified button is pressed 244 | // (a in this case) 245 | 246 | // change to or mode fire irq 247 | mov r5, #0x40 248 | strb r5, [r4,#1] 249 | 250 | // filter by 'A' 251 | mov r5, #1 252 | strb r5, [r4] 253 | 254 | // wait for no input 255 | mvn r0, #0 256 | bl button_wait 257 | 258 | // wait for a 259 | mvn r0, #1 260 | bl button_wait 261 | 262 | // check intr fired 263 | ldrh r5, [r3] 264 | and r5, #4096 265 | cmp r5, #4096 266 | 267 | bne or_select_fail 268 | 269 | ldr r0, =ok_string 270 | 271 | b or_select_print 272 | 273 | or_select_fail: 274 | ldr r0, =fail_string 275 | 276 | or_select_print: 277 | bl write 278 | 279 | 280 | // check or mode does not fire when the selected button is not pressed 281 | 282 | ldr r0, =press_b 283 | bl write 284 | 285 | ldr r0, =or_no_select 286 | bl write 287 | 288 | // wait for no input 289 | mvn r0, #0 290 | bl button_wait 291 | 292 | // wait for b 293 | mvn r0, #2 294 | bl button_wait 295 | 296 | // check no intr fired 297 | ldrh r5, [r3] 298 | and r5, #4096 299 | cmp r5, #4096 300 | 301 | beq or_no_select_fail 302 | 303 | ldr r0, =ok_string 304 | 305 | b or_no_select_print 306 | 307 | or_no_select_fail: 308 | ldr r0, =fail_string 309 | 310 | or_no_select_print: 311 | bl write 312 | 313 | 314 | ldr r0, =done 315 | bl write 316 | 317 | 318 | infin: 319 | b infin 320 | 321 | 322 | unpressed_high_string: 323 | .asciz "unpressed high: " 324 | 325 | and_no_select: 326 | .asciz "\nand_no_select: " 327 | 328 | and_select: 329 | .asciz "\nand_select: " 330 | 331 | and_no_intr: 332 | .asciz "\nand_no_intr: " 333 | 334 | and_no_irq: 335 | .asciz "\nand_no_irq: " 336 | 337 | or_select: 338 | .asciz "\nor_select: " 339 | 340 | or_no_select: 341 | .asciz "\nor_no_select: " 342 | 343 | 344 | press_a_and_b: 345 | .asciz "\npress a and b" 346 | 347 | press_a: 348 | .asciz "\npress a" 349 | 350 | press_b: 351 | .asciz "\npress b" 352 | 353 | ok_string: 354 | .asciz "ok" 355 | 356 | fail_string: 357 | .asciz "fail" 358 | 359 | 360 | and_string: 361 | .asciz "\n****and_tests****" 362 | 363 | or_string: 364 | .asciz "\n****or_tests****" 365 | 366 | 367 | done: 368 | .asciz "\nyour emulator sucks?\n" -------------------------------------------------------------------------------- /isr/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /if_ack/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /template/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /cond_invalid/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /dma_priority/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /hello_world/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /line_timing/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /lyc_midline/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /experimental/joypad/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /experimental/pcmxx/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /window_midframe/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /experimental/irq_delay/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /experimental/timer_change/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(DEVKITARM)),) 7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM) 8 | endif 9 | 10 | include $(DEVKITARM)/gba_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output, if this ends with _mb a multiboot image is generated 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | #--------------------------------------------------------------------------------- 19 | TARGET := $(shell basename $(CURDIR)) 20 | BUILD := build 21 | SOURCES := source 22 | DATA := 23 | GRAPHICS := gfx 24 | INCLUDES := 25 | 26 | #--------------------------------------------------------------------------------- 27 | # options for code generation 28 | #--------------------------------------------------------------------------------- 29 | ARCH := -mthumb -mthumb-interwork 30 | 31 | CFLAGS := -g -Wall -O3\ 32 | -mcpu=arm7tdmi -mtune=arm7tdmi\ 33 | -fomit-frame-pointer\ 34 | -ffast-math \ 35 | $(ARCH) 36 | 37 | CFLAGS += $(INCLUDE) 38 | 39 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 40 | 41 | ASFLAGS := $(ARCH) 42 | LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lgba 48 | 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(LIBGBA) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 64 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 65 | 66 | export DEPSDIR := $(CURDIR)/$(BUILD) 67 | 68 | #--------------------------------------------------------------------------------- 69 | # automatically build a list of object files for our project 70 | #--------------------------------------------------------------------------------- 71 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 72 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 73 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 74 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 75 | BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # use CXX for linking C++ projects, CC for standard C 79 | #--------------------------------------------------------------------------------- 80 | ifeq ($(strip $(CPPFILES)),) 81 | #--------------------------------------------------------------------------------- 82 | export LD := $(CC) 83 | #--------------------------------------------------------------------------------- 84 | else 85 | #--------------------------------------------------------------------------------- 86 | export LD := $(CXX) 87 | #--------------------------------------------------------------------------------- 88 | endif 89 | #--------------------------------------------------------------------------------- 90 | 91 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 92 | $(BMPFILES:.bmp=.o) \ 93 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 94 | 95 | #--------------------------------------------------------------------------------- 96 | # build a list of include paths 97 | #--------------------------------------------------------------------------------- 98 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 99 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 100 | -I$(CURDIR)/$(BUILD) 101 | 102 | #--------------------------------------------------------------------------------- 103 | # build a list of library paths 104 | #--------------------------------------------------------------------------------- 105 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 106 | 107 | .PHONY: $(BUILD) clean 108 | 109 | #--------------------------------------------------------------------------------- 110 | $(BUILD): 111 | @[ -d $@ ] || mkdir -p $@ 112 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | all : $(BUILD) 115 | #--------------------------------------------------------------------------------- 116 | clean: 117 | @echo clean ... 118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba 119 | 120 | #--------------------------------------------------------------------------------- 121 | else 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #--------------------------------------------------------------------------------- 126 | # main targets 127 | #--------------------------------------------------------------------------------- 128 | $(OUTPUT).gba : $(OUTPUT).elf 129 | 130 | $(OUTPUT).elf : $(OFILES) 131 | 132 | 133 | #--------------------------------------------------------------------------------- 134 | # The bin2o rule should be copied and modified 135 | # for each extension used in the data directories 136 | #--------------------------------------------------------------------------------- 137 | 138 | #--------------------------------------------------------------------------------- 139 | # This rule links in binary data with the .bin extension 140 | #--------------------------------------------------------------------------------- 141 | %.bin.o : %.bin 142 | #--------------------------------------------------------------------------------- 143 | @echo $(notdir $<) 144 | @$(bin2o) 145 | 146 | #--------------------------------------------------------------------------------- 147 | # This rule links in binary data with the .raw extension 148 | #--------------------------------------------------------------------------------- 149 | %.raw.o : %.raw 150 | #--------------------------------------------------------------------------------- 151 | @echo $(notdir $<) 152 | @$(bin2o) 153 | 154 | #--------------------------------------------------------------------------------- 155 | # This rule creates assembly source files using grit 156 | # grit takes an image file and a .grit describing how the file is to be processed 157 | # add additional rules like this for each image extension 158 | # you use in the graphics folders 159 | #--------------------------------------------------------------------------------- 160 | %.s %.h : %.bmp %.grit 161 | #--------------------------------------------------------------------------------- 162 | grit $< -fts -o$* 163 | 164 | -include $(DEPENDS) 165 | 166 | #--------------------------------------------------------------------------------- 167 | endif 168 | #--------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /isr/source/isr.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | .text 4 | /* 5 | checks the timing of isrs 6 | and that the return address is set properly 7 | irq delay throws this test off 8 | with no irq delay you should get 8 & 6 for the lr returns 9 | and with it you should get 10 & A 10 | unccoment the str near the arm intr trigger if you want to test the irq delay a little more 11 | */ 12 | isr: 13 | 14 | // ackknowledge intr and pull timer 15 | mov r1, #0x04000000 16 | add r1, #0x100 17 | 18 | ldrh r3, [r1] 19 | 20 | add r1, #0x100 21 | add r1, #2 22 | 23 | mov r0, #0xffffffff 24 | strh r0, [r1] 25 | 26 | // dump some vars 27 | mov r8, #0x02000000 28 | add r8, #0x400 29 | 30 | // notify of an intr trigger 31 | mov r1, #1 32 | str r1, [r8] 33 | 34 | // store the time for it to fire 35 | str r3, [r8, #4] 36 | 37 | mov r7, lr 38 | 39 | // store the lr pushed to return to the mode intr was called from 40 | // the bios after calling our handler wille execute this instr 41 | // with a stack writeback 42 | ldmfd r13, {r0-r3,r12,r14} 43 | 44 | str lr, [r8, #8] 45 | 46 | mov lr, r7 47 | bx lr 48 | isr_end: 49 | 50 | isr_size = isr_end - isr 51 | 52 | 53 | 54 | 55 | 56 | fire_intr_arm: 57 | strh r3, [r2] 58 | 59 | // irq delay shenanigans 60 | // (uncomment either) 61 | //strh r5, [r2,#8] 62 | //strh r5, [r2] 63 | //strh r9, [r2,#2] 64 | 65 | //msr cpsr, r8 66 | //msr cpsr,r10 67 | //msr cpsr, r8 68 | 69 | // nop sled here in case the return addr is off 70 | nop 71 | nop 72 | nop 73 | nop 74 | nop 75 | nop 76 | nop 77 | nop 78 | nop 79 | nop 80 | nop 81 | nop 82 | 83 | // reset cpsr after our shenanigans 84 | msr cpsr,r10 85 | 86 | // save cpsr 87 | mrs r7, cpsr 88 | 89 | bx lr 90 | 91 | .word 0xdeadbeef 92 | 93 | fire_intr_arm_end: 94 | 95 | fire_intr_arm_size = fire_intr_arm_end - fire_intr_arm 96 | 97 | 98 | 99 | 100 | intr_test_arm: 101 | push {r0-r7,lr} 102 | 103 | ldr r1, =#0x04000202 104 | 105 | // wait for a vblank intr 106 | // we will use this to force an intr later 107 | vblank_wait_arm: 108 | ldrh r3, [r1] 109 | and r3, #1 110 | cmp r3, #1 111 | bne vblank_wait_arm 112 | 113 | 114 | 115 | 116 | 117 | // setup timer 0 to count the intr time 118 | // setup the timers 119 | ldr r0, =#0x04000100 120 | mov r1, #0 121 | strh r1, [r0] 122 | strh r1, [r0,#2] 123 | mov r1, #0x80 124 | strh r1, [r0,#2] 125 | 126 | 127 | // preload some vars for reading out results 128 | mov r4, #0x02000000 129 | add r4, #0x400 130 | 131 | 132 | // set ie mask to allow all 133 | ldr r2, =#0x04000200 134 | mov r3, #0xffffffff 135 | 136 | 137 | 138 | // force an intr 139 | // make sure your pipeline is full if you emulate it 140 | // or youll get some nice behavior 141 | ldr r7, =#0xdeadbeef // make it obv if you dont read cpsr back nicely 142 | mov r5, #0 143 | mov r9, #0xffffffff 144 | 145 | // via cpsr 146 | mrs r8, cpsr 147 | mov r10, r8 148 | orr r8, #128 149 | 150 | ldr lr, =fire_intr_arm_return 151 | ldr r0, =#0x03000400 + isr_size 152 | bx r0 153 | 154 | 155 | // returns to this label! 156 | fire_intr_arm_return: 157 | 158 | ldr r1, [r4] 159 | cmp r1, #1 160 | beq intr_fired_arm 161 | 162 | ldr r0, =no_intr_string 163 | bl write 164 | 165 | b infin 166 | 167 | intr_fired_arm: 168 | // print the results 169 | 170 | 171 | ldr r0, =intr_fired_string 172 | bl write 173 | 174 | ldr r0, =timer_string 175 | bl write 176 | 177 | ldr r0, [r4,#4] 178 | bl print_hex 179 | 180 | 181 | ldr r0, =arm_lr_string 182 | bl write 183 | 184 | // calc the lr relative to the intr 185 | ldr r0, [r4, #8] 186 | ldr r1, =#0x03000400 + isr_size 187 | sub r0, r1 188 | 189 | bl print_hex 190 | 191 | ldr r0, =cpsr_string 192 | bl write 193 | mov r0, r7 194 | bl print_hex 195 | 196 | pop {r0-r7,lr} 197 | bx lr 198 | 199 | 200 | .thumb 201 | intr_test_thumb: 202 | ldr r1, =#0x04000202 203 | 204 | // wait for a vblank intr 205 | // we will use this to force an intr later 206 | mov r2, #1 207 | vblank_wait_thumb: 208 | ldrh r3, [r1] 209 | and r3, r2 210 | cmp r3, #1 211 | bne vblank_wait_thumb 212 | 213 | 214 | 215 | 216 | 217 | // setup timer 0 to count the intr time 218 | // setup the timers 219 | ldr r0, =#0x04000100 220 | mov r1, #0 221 | strh r1, [r0] 222 | strh r1, [r0,#2] 223 | mov r1, #0x80 224 | strh r1, [r0,#2] 225 | 226 | 227 | // preload some vars for reading out results 228 | ldr r4, =#0x02000400 229 | 230 | // set ie mask to allow all 231 | ldr r2, =#0x04000200 232 | ldr r3, =#0xffffffff 233 | 234 | 235 | 236 | // force an intr 237 | // make sure your pipeline is full if you emulate it 238 | // or youll get some nice behavior 239 | fire_intr_thumb: 240 | strh r3, [r2] 241 | 242 | // nop sled here in case the return addr is off 243 | nop 244 | nop 245 | nop 246 | nop 247 | nop 248 | nop 249 | 250 | ldr r1, [r4] 251 | cmp r1, #1 252 | beq intr_fired_thumb 253 | 254 | thumb_infin: 255 | b thumb_infin 256 | 257 | intr_fired_thumb: 258 | ldr r2, [r4, #8] 259 | ldr r3, =#fire_intr_thumb 260 | sub r2,r3 261 | 262 | 263 | 264 | 265 | 266 | 267 | ldr r0, =return_thumb 268 | bx r0 269 | 270 | 271 | 272 | .arm 273 | 274 | main: 275 | // turn off interrupts 276 | ldr r1, =#0x04000208 277 | str r1, [r1] 278 | 279 | bl init_text 280 | 281 | // copy our isr to wram 282 | ldr r0, =#0x03000400 283 | ldr r1, =isr 284 | ldr r2, =isr_size 285 | 286 | bl memcpy 287 | 288 | 289 | ldr r0, =#0x03000400 + isr_size 290 | ldr r1, =fire_intr_arm 291 | ldr r2, =fire_intr_arm_size 292 | 293 | bl memcpy 294 | 295 | 296 | 297 | // setup our isr pointer 298 | ldr r0, =#0x03007FFC 299 | ldr r1, =#0x03000400 300 | str r1,[r0] 301 | 302 | // ldr r0 303 | 304 | // enable interrupt servicing 305 | ldr r1, =#0x04000208 306 | mov r0, #1 307 | str r0, [r1] 308 | 309 | // enable the vblank intr 310 | ldr r1, =#0x04000004 311 | mov r0, #8 312 | strh r0, [r1] 313 | 314 | bl intr_test_arm 315 | 316 | // set ie mask to disallow all 317 | ldr r2, =#0x04000200 318 | mov r3, #0 319 | 320 | strh r3, [r2] 321 | 322 | 323 | ldr r0, =intr_test_thumb 324 | add r0, #1 325 | bx r0 326 | 327 | return_thumb: 328 | 329 | ldr r0, =thumb_lr_string 330 | bl write 331 | 332 | // calc the lr relative to the intr 333 | mov r0, r2 334 | 335 | bl print_hex 336 | 337 | 338 | 339 | // ok now we are going to test swi return addresses 340 | ldr r0, =swi_string 341 | bl write 342 | mov r12, #0 343 | swi #0x80000 344 | 345 | // ok lets jam 5 incs to get a rough indicator of where this should return 346 | add r12, #1 347 | add r12, #1 348 | add r12, #1 349 | add r12, #1 350 | add r12, #1 351 | 352 | 353 | sub r0, r12, #4 354 | lsl r0, #2 355 | bl print_hex 356 | 357 | 358 | 359 | 360 | 361 | infin: 362 | b infin 363 | 364 | 365 | 366 | .data 367 | 368 | 369 | no_intr_string: 370 | .asciz "no interrupt" 371 | 372 | intr_fired_string: 373 | .asciz "interrupt fired\n" 374 | 375 | cpsr_string: 376 | .asciz "\ncpsr: " 377 | 378 | timer_string: 379 | .asciz "timer: " 380 | 381 | arm_lr_string: 382 | .asciz "\narm lr: " 383 | thumb_lr_string: 384 | .asciz "\nthumb lr: " 385 | 386 | 387 | swi_string: 388 | .asciz "\nswi: \n" 389 | 390 | 391 | 392 | -------------------------------------------------------------------------------- /dma_priority/source/dma.s: -------------------------------------------------------------------------------- 1 | .global main 2 | .arm 3 | .text 4 | 5 | 6 | /* 7 | tests priority of dma's 8 | by dmaing to the control regs with another dma 9 | */ 10 | 11 | 12 | 13 | //r0 dest 14 | //r1 source 15 | //r2 dma reg 16 | //r3 control 17 | //r4 size (in bytes) 18 | test_dma: 19 | push {r0-r6,lr} 20 | 21 | // where we test dmas too 22 | ldr r6, =#0x03000000 23 | 24 | // reset the value each time 25 | mov r5, #0 26 | str r5, [r6] 27 | 28 | // mov dest to r5 so its easier 29 | mov r5, r0 30 | 31 | // convert to word ammount 32 | // (ideally we shouldunt assume that our control is of this type if we were to reusue this) 33 | lsr r4, #2 34 | 35 | ldr r0, =before_string 36 | bl write 37 | 38 | ldr r0, [r6] 39 | 40 | bl print_hex 41 | 42 | 43 | str r1, [r2] // write source 44 | str r5, [r2,#4] // write dest 45 | strh r4, [r2,#8] // write word count 46 | strh r3, [r2,#0xa] // write control 47 | 48 | 49 | // write out result 50 | ldr r0, =after_string 51 | bl write 52 | ldr r0, [r6] 53 | bl print_hex 54 | 55 | 56 | pop {r0-r6,lr} 57 | bx lr 58 | 59 | 60 | 61 | 62 | // hack of above fucntion 63 | // to flash screen red 64 | // incase of hardware lockups 65 | 66 | .text 67 | //r0 dest 68 | //r1 source 69 | //r2 dma reg 70 | //r3 control 71 | //r4 size (in bytes) 72 | test_dma_hack: 73 | push {r0-r6,lr} 74 | 75 | // where we test dmas too 76 | ldr r6, =#0x03000000 77 | 78 | // reset the value each time 79 | mov r5, #0 80 | str r5, [r6] 81 | 82 | // mov dest to r5 so its easier 83 | mov r5, r0 84 | 85 | // convert to word ammount 86 | // (ideally we shouldunt assume that our control is of this type if we were to reusue this) 87 | lsr r4, #2 88 | 89 | ldr r0, =before_string 90 | bl write 91 | 92 | ldr r0, [r6] 93 | 94 | bl print_hex 95 | 96 | 97 | str r1, [r2] // write source 98 | str r5, [r2,#4] // write dest 99 | strh r4, [r2,#8] // write word count 100 | strh r3, [r2,#0xa] // write control 101 | 102 | // ok the dma might have completly 103 | // screwed the entire of memory 104 | // lets try smash a red screen 105 | // if we dont get it that means the hardware 106 | // has complelty locked up... 107 | 108 | mov r0, #0x04000000 // dispcnt 109 | ldr r1, =#0x403 110 | strh r1, [r0] 111 | 112 | 113 | //memcpy red into vram :P 114 | mov r0, #0x06000000 115 | mov r1, #31 116 | ldr r2, =#0x06012c00 117 | 118 | vram_loop: 119 | strh r1, [r0] 120 | add r0, #2 121 | cmp r2, r0 122 | bne vram_loop 123 | 124 | infin_2: 125 | b infin_2 126 | /* 127 | // write out result 128 | ldr r0, =after_string 129 | bl write 130 | ldr r0, [r6] 131 | bl print_hex 132 | 133 | 134 | 135 | 136 | 137 | pop {r0-r6,lr} 138 | bx lr 139 | */ 140 | 141 | 142 | main: 143 | // turn off interrupts 144 | ldr r1, =#0x04000208 145 | str r1, [r1] 146 | 147 | 148 | // write waitstates to max so we dont get any bugs 149 | ldr r1, =#0x04000204 150 | ldr r2, =#0xfffffff 151 | str r2, [r1] 152 | 153 | bl init_text 154 | 155 | 156 | 157 | // test 1 158 | // ok lets just test doing a straight up dma to 0x03000000 159 | // to check the value is overwritten 160 | ldr r0, =test1_string 161 | bl write 162 | 163 | 164 | ldr r0, =#0x03000000 // dest 165 | ldr r1, =test1_data // source 166 | ldr r2, =#0x040000b0 //dma0 167 | ldr r3, =#0b1000010000000000 // enable word size 168 | mov r4, #4 169 | bl test_dma 170 | 171 | 172 | 173 | 174 | // test2 175 | // test two dma regs in order 176 | 177 | ldr r0, =test2_string 178 | bl write 179 | 180 | //(need to write some garbage before to avoid lockups on hardware) 181 | // dma0 start - 24 182 | // wil write to dma0 then dma 1 183 | ldr r0, =#0x040000b0-24// dest 184 | 185 | ldr r1, =dma_info // source 186 | ldr r2, =#0x040000d4 //dma3 187 | ldr r3, =#0b1000010000000000 // enable word size 188 | ldr r4, =dma_info_size-24 189 | bl test_dma 190 | 191 | 192 | 193 | // test3 194 | // test two dma regs in reverse order 195 | // 3 then 2 196 | // (does not work) 197 | ldr r0, =test3_string 198 | bl write 199 | 200 | //(need to write some garbage before to avoid lockups on hardware) 201 | // dma3 end + 24 202 | ldr r0, =#0x040000de + 24// dest 203 | 204 | ldr r1, =dma_info_end // source 205 | ldr r2, =#0x040000b0 //dma0 206 | ldr r3, =#0b1000010010100000 // enable word size (minus dst, minus src) 207 | ldr r4, =dma_info_size-24 208 | bl test_dma 209 | 210 | 211 | 212 | // test4 dma to self enable during xfer 213 | // should not execute dma 214 | 215 | ldr r0, =test4_string 216 | bl write 217 | 218 | ldr r0, =#0x040000d4 219 | ldr r1, =dma_info+24 220 | mov r2, r0 221 | ldr r3, =#0b1000010000000000 // enable word size 222 | mov r4, #12 223 | bl test_dma 224 | /* 225 | //inc version (locks up on hardware appears to trash ram without a dma end) 226 | // TODO find out why 227 | 228 | // tes5 4 dma to self disable during xfer 229 | // if it disables the next dma reg wont get written 230 | // and tehre wont be a dump 231 | // 0 then 1 232 | 233 | 234 | ldr r0, =test5_string 235 | bl write 236 | 237 | ldr r0, =#0x040000b0-24 238 | ldr r1, =dma_cancel 239 | ldr r2, =#0x040000b0 // dma 0 240 | ldr r3, =#0b1000010000000000 // enable word size 241 | ldr r4, =dma_cancel_size-36 242 | //bl test_dma_hack 243 | bl test_dma 244 | */ 245 | 246 | 247 | // dec version 248 | 249 | // test 5 4 dma to self disable during xfer 250 | // if it disables the next dma reg wont get written 251 | // and tehre wont be a dump 252 | // 3 then 2 253 | // appears to disable on hardware 254 | 255 | ldr r0, =test5_string 256 | bl write 257 | 258 | ldr r0, =#0x040000d4+24 259 | ldr r1, =dma_cancel_end 260 | ldr r2, =#0x040000d4 // dma 0 261 | ldr r3, =#0b1000010010100000 262 | ldr r4, =dma_cancel_size-36 263 | bl test_dma 264 | 265 | 266 | infin: 267 | b infin 268 | 269 | 270 | 271 | .data 272 | 273 | // reserve first part for ourself :P 274 | .word 0x0 275 | 276 | test1_data: 277 | .word 0xdeadbeef 278 | 279 | 280 | dma2_data: 281 | .word 0x2 282 | dma1_data: 283 | .word 0x1 284 | 285 | 286 | dma_info: 287 | 288 | 289 | // dummy data either side 290 | // so we can delay starting dmas 291 | .word 0x0 292 | .word 0x0 293 | .word 0x0 294 | 295 | .word 0x0 296 | .word 0x0 297 | .word 0x0 298 | 299 | 300 | // dma 1 301 | .word dma1_data 302 | .word 0x03000000 303 | .word 0x85400001 304 | 305 | // (fixed) xfer one word 306 | // 1000010101000000 = 0x8540 307 | 308 | // dma 2 309 | .word dma2_data 310 | .word 0x03000000 311 | .word 0x85400001 312 | 313 | // dummy data either side 314 | 315 | .word 0x0 316 | .word 0x0 317 | .word 0x0 318 | 319 | .word 0x0 320 | .word 0x0 321 | .word 0x0 322 | 323 | 324 | dma_info_end: 325 | 326 | dma_info_size = dma_info_end - dma_info 327 | 328 | 329 | 330 | dma_cancel: 331 | .word 0x0 332 | .word 0x0 333 | .word 0x0 334 | 335 | .word 0x0 336 | .word 0x0 337 | .word 0x0 338 | 339 | // dma 0 340 | .word 0x0 341 | .word 0x0 342 | .word 0x0 343 | 344 | // dma 1 / 2 345 | .word dma1_data 346 | .word 0x03000000 347 | .word 0x85400001 348 | 349 | // dummy data either side 350 | 351 | // dma3 352 | .word 0x0 353 | .word 0x0 354 | .word 0x0 355 | 356 | .word 0x0 357 | .word 0x0 358 | .word 0x0 359 | 360 | .word 0x0 361 | .word 0x0 362 | .word 0x0 363 | 364 | 365 | dma_cancel_end: 366 | 367 | dma_cancel_size = dma_cancel_end - dma_cancel 368 | 369 | 370 | before_string: 371 | .asciz "before: " 372 | 373 | after_string: 374 | .asciz "\nafter: " 375 | 376 | 377 | test1_string: 378 | .asciz "test 1 basic dma\n" 379 | 380 | test2_string: 381 | .asciz "\ntest 2 forward priority\n" 382 | 383 | test3_string: 384 | .asciz "\ntest 3 reverse priority\n" 385 | 386 | test4_string: 387 | .asciz "\ntest 4 dma to self enable\n" 388 | 389 | test5_string: 390 | .asciz "\ntest 5 dma to self disable\n" -------------------------------------------------------------------------------- /isr/source/text.s: -------------------------------------------------------------------------------- 1 | .global init_text 2 | .global putchar 3 | .global write 4 | .global print_hex 5 | 6 | 7 | .data 8 | 9 | // 1bpp encoding 10 | font_tiles: 11 | 12 | // font taken from https://www.coranac.com/tonc/text/text.htm 13 | 14 | .word 0x00000000, 0x00000000, 0x18181818, 0x00180018, 0x00003636, 0x00000000, 0x367F3636, 0x0036367F 15 | .word 0x3C067C18, 0x00183E60, 0x1B356600, 0x0033566C, 0x6E16361C, 0x00DE733B, 0x000C1818, 0x00000000 16 | .word 0x0C0C1830, 0x0030180C, 0x3030180C, 0x000C1830, 0xFF3C6600, 0x0000663C, 0x7E181800, 0x00001818 17 | .word 0x00000000, 0x0C181800, 0x7E000000, 0x00000000, 0x00000000, 0x00181800, 0x183060C0, 0x0003060C 18 | .word 0x7E76663C, 0x003C666E, 0x181E1C18, 0x00181818, 0x3060663C, 0x007E0C18, 0x3860663C, 0x003C6660 19 | .word 0x33363C38, 0x0030307F, 0x603E067E, 0x003C6660, 0x3E060C38, 0x003C6666, 0x3060607E, 0x00181818 20 | .word 0x3C66663C, 0x003C6666, 0x7C66663C, 0x001C3060, 0x00181800, 0x00181800, 0x00181800, 0x0C181800 21 | .word 0x06186000, 0x00006018, 0x007E0000, 0x0000007E, 0x60180600, 0x00000618, 0x3060663C, 0x00180018 22 | .word 0x5A5A663C, 0x003C067A, 0x7E66663C, 0x00666666, 0x3E66663E, 0x003E6666, 0x06060C78, 0x00780C06 23 | .word 0x6666361E, 0x001E3666, 0x1E06067E, 0x007E0606, 0x1E06067E, 0x00060606, 0x7606663C, 0x007C6666 24 | .word 0x7E666666, 0x00666666, 0x1818183C, 0x003C1818, 0x60606060, 0x003C6660, 0x0F1B3363, 0x0063331B 25 | .word 0x06060606, 0x007E0606, 0x6B7F7763, 0x00636363, 0x7B6F6763, 0x00636373, 0x6666663C, 0x003C6666 26 | .word 0x3E66663E, 0x00060606, 0x3333331E, 0x007E3B33, 0x3E66663E, 0x00666636, 0x3C0E663C, 0x003C6670 27 | .word 0x1818187E, 0x00181818, 0x66666666, 0x003C6666, 0x66666666, 0x00183C3C, 0x6B636363, 0x0063777F 28 | .word 0x183C66C3, 0x00C3663C, 0x183C66C3, 0x00181818, 0x0C18307F, 0x007F0306, 0x0C0C0C3C, 0x003C0C0C 29 | .word 0x180C0603, 0x00C06030, 0x3030303C, 0x003C3030, 0x00663C18, 0x00000000, 0x00000000, 0x003F0000 30 | .word 0x00301818, 0x00000000, 0x603C0000, 0x007C667C, 0x663E0606, 0x003E6666, 0x063C0000, 0x003C0606 31 | .word 0x667C6060, 0x007C6666, 0x663C0000, 0x003C067E, 0x0C3E0C38, 0x000C0C0C, 0x667C0000, 0x3C607C66 32 | .word 0x663E0606, 0x00666666, 0x18180018, 0x00301818, 0x30300030, 0x1E303030, 0x36660606, 0x0066361E 33 | .word 0x18181818, 0x00301818, 0x7F370000, 0x0063636B, 0x663E0000, 0x00666666, 0x663C0000, 0x003C6666 34 | .word 0x663E0000, 0x06063E66, 0x667C0000, 0x60607C66, 0x663E0000, 0x00060606, 0x063C0000, 0x003E603C 35 | .word 0x0C3E0C0C, 0x00380C0C, 0x66660000, 0x007C6666, 0x66660000, 0x00183C66, 0x63630000, 0x00367F6B 36 | .word 0x36630000, 0x0063361C, 0x66660000, 0x0C183C66, 0x307E0000, 0x007E0C18, 0x0C181830, 0x00301818 37 | .word 0x18181818, 0x00181818, 0x3018180C, 0x000C1818, 0x003B6E00, 0x00000000, 0x00000000, 0x00000000 38 | 39 | font_tiles_end: 40 | 41 | 42 | 43 | font_tiles_size = font_tiles_end - font_tiles 44 | 45 | 46 | .arm 47 | .text 48 | 49 | /* 50 | void no args 51 | */ 52 | init_text: 53 | 54 | push {r0-r7} 55 | 56 | // dispcnt enable bg1 text mode 0 57 | mov r0, #0x04000000 58 | mov r1, #0x100 59 | strh r1, [r0] 60 | 61 | # bg1cnt 4bpp max priority 62 | # relocate bg map 63 | mov r1, #0x800 64 | strh r1, [r0,#0x8] 65 | 66 | # setup palette 67 | mov r0, #0x05000000 68 | // yeah i know we only use the bottom of this 69 | mov r1, #0xffffffff 70 | strh r1, [r0,#2] 71 | 72 | 73 | mov r0, #0x06000000 74 | ldr r1, =font_tiles_size 75 | ldr r2, =font_tiles 76 | 77 | 78 | // 1bpp packing to 4bpp 79 | // so take a byte and for each byte 80 | // unpack 2 bits into a nibble 81 | // store in vram 82 | 83 | tile_copy_loop: 84 | // load our tile data 85 | ldrb r3, [r2,r1] 86 | 87 | // we load two bits at a time out of this 88 | // so 4 instead of 8 89 | mov r4, #4 90 | 91 | # reset our reg we are decoding the data into 92 | mov r5, #0 93 | unpack_loop: 94 | // shift up our decoded data 95 | lsl r5, #8 96 | 97 | // load low nibble 98 | and r6, r3, #128 99 | lsr r6, #7 100 | lsl r3, #1 101 | lsl r6, #4 102 | 103 | // load high nibble 104 | and r7, r3, #128 105 | lsr r7, #7 106 | lsl r3, #1 107 | 108 | # combine current byte into word 109 | orr r6, r7 110 | orr r5, r6 111 | 112 | 113 | // if we still have data in the byte keep doing 114 | subs r4, #0x1 115 | bne unpack_loop 116 | 117 | // unpack is done our decoded 118 | // 4bpp tile should be in r4 119 | // need to *4 r0 as our output 120 | // is 4 times larger 121 | str r5, [r0,r1, lsl #0x2] 122 | 123 | 124 | subs r1, #1 125 | bne tile_copy_loop 126 | 127 | 128 | // reset our text counters 129 | // how to define this as a constant? 130 | mov r0, #0x02000000 131 | strb r1, [r0] // col 132 | strb r1, [r0,#1] // row 133 | 134 | pop {r0-r7} 135 | bx lr 136 | 137 | 138 | // r0: char to print 139 | // void return 140 | putchar: 141 | push {r0-r5} 142 | 143 | // get bg col and row 144 | mov r2, #0x02000000 145 | ldrb r3, [r2] 146 | ldrb r4, [r2,#1] 147 | 148 | // load bg map offset 149 | ldr r1, =#0x06004000 150 | 151 | // check for linefeed 152 | cmp r0, #0xa 153 | beq inc_row 154 | 155 | 156 | 157 | 158 | // if in the printable ascii range 159 | cmp r0, #0x20 160 | // ignore non printable chars 161 | blt putchar_end 162 | 163 | cmp r0, #0x7e 164 | bgt putchar_end 165 | 166 | // convert to printable range 167 | sub r0, #0x20 168 | 169 | 170 | // calc bg offset 171 | 172 | // calc col offset 173 | mov r5, r3, lsl #1 174 | 175 | // calc row offset 176 | add r5, r4, lsl #6 177 | 178 | 179 | 180 | // store the char 181 | strh r0, [r5,r1] 182 | 183 | // inc row and check we havent gone past screen size 184 | add r3, #1 185 | cmp r3, #30 186 | 187 | bne store_cords 188 | 189 | inc_row: 190 | // reset col and goto next row 191 | mov r3, #0 192 | add r4,#1 193 | 194 | // end of screen copy each one up 195 | cmp r4, #20 196 | bne store_cords 197 | 198 | // bg line size 199 | mov r2, #64 200 | 201 | // transfer limit 202 | add r3, r1, #0x500 203 | 204 | // r0 dst, r1 source 205 | mov r0, r1 206 | add r1, r2 207 | 208 | row_copy_loop: 209 | push {lr} 210 | bl memcpy 211 | pop {lr} 212 | 213 | // inc dst, src 214 | add r0, r2 215 | add r1, r2 216 | 217 | // if src is at line 20 we are done 218 | cmp r0, r3 219 | bne row_copy_loop 220 | 221 | // last line col zero 222 | mov r3, #0 223 | mov r4, #19 224 | mov r2, #0x02000000 225 | 226 | 227 | 228 | store_cords: 229 | strb r3, [r2] 230 | strb r4, [r2,#1] 231 | 232 | putchar_end: 233 | pop {r0-r5} 234 | bx lr 235 | 236 | 237 | // r0: pointer to string 238 | // void return 239 | write: 240 | push {r0-r1} 241 | 242 | mov r1, r0 243 | 244 | // while not zero putchar 245 | write_loop: 246 | ldrb r0, [r1], #1 247 | cmp r0, #0x0 248 | beq write_done 249 | push {lr} 250 | bl putchar 251 | pop {lr} 252 | b write_loop 253 | 254 | 255 | write_done: 256 | pop {r0-r1} 257 | bx lr 258 | 259 | 260 | 261 | 262 | // r0 number to print 263 | // void return 264 | print_hex: 265 | push {r0-r2} 266 | 267 | 268 | // get each nibble of the arg 269 | // and convert it to a char 270 | mov r1, r0 271 | 272 | mov r2, #8 273 | hex_loop: 274 | and r0, r1, #0xf0000000 275 | lsr r0, #28 276 | lsl r1, #4 277 | cmp r0, #9 278 | bgt conv_upper_hex 279 | // convert to a number 280 | add r0, #48 281 | b hex_printchar 282 | 283 | conv_upper_hex: 284 | // this now above ten so convert to 'a' - 'f' 285 | add r0, #55 286 | 287 | 288 | hex_printchar: 289 | push {lr} 290 | bl putchar 291 | pop {lr} 292 | 293 | subs r2, #1 294 | bne hex_loop 295 | 296 | pop {r0-r2} 297 | bx lr 298 | 299 | 300 | // need to these to handle bus limitations 301 | // otherwhise they will not copy properly 302 | 303 | 304 | 305 | // currently wont handle a odd transfer size... 306 | 307 | // r0 dest 308 | // r1 src 309 | // r2 size 310 | // void return 311 | memcpy: 312 | push {r2-r3} 313 | 314 | // ignore 0th bit 315 | mvn r3, #1 316 | and r2, r3 317 | memcpy_loop: 318 | ldrh r3, [r1,r2] 319 | strh r3, [r0,r2] 320 | subs r2, #2 321 | bne memcpy_loop 322 | 323 | pop {r2-r3} 324 | bx lr 325 | 326 | 327 | // r0 dest 328 | // r1 val 329 | // r2 size 330 | memset: 331 | push {r2} 332 | memset_loop: 333 | strb r1, [r0, r2] 334 | subs r2, #1 335 | bne memset_loop 336 | 337 | pop {r2} 338 | bx lr -------------------------------------------------------------------------------- /if_ack/source/text.s: -------------------------------------------------------------------------------- 1 | .global init_text 2 | .global putchar 3 | .global write 4 | .global print_hex 5 | 6 | 7 | .data 8 | 9 | // 1bpp encoding 10 | font_tiles: 11 | 12 | // font taken from https://www.coranac.com/tonc/text/text.htm 13 | 14 | .word 0x00000000, 0x00000000, 0x18181818, 0x00180018, 0x00003636, 0x00000000, 0x367F3636, 0x0036367F 15 | .word 0x3C067C18, 0x00183E60, 0x1B356600, 0x0033566C, 0x6E16361C, 0x00DE733B, 0x000C1818, 0x00000000 16 | .word 0x0C0C1830, 0x0030180C, 0x3030180C, 0x000C1830, 0xFF3C6600, 0x0000663C, 0x7E181800, 0x00001818 17 | .word 0x00000000, 0x0C181800, 0x7E000000, 0x00000000, 0x00000000, 0x00181800, 0x183060C0, 0x0003060C 18 | .word 0x7E76663C, 0x003C666E, 0x181E1C18, 0x00181818, 0x3060663C, 0x007E0C18, 0x3860663C, 0x003C6660 19 | .word 0x33363C38, 0x0030307F, 0x603E067E, 0x003C6660, 0x3E060C38, 0x003C6666, 0x3060607E, 0x00181818 20 | .word 0x3C66663C, 0x003C6666, 0x7C66663C, 0x001C3060, 0x00181800, 0x00181800, 0x00181800, 0x0C181800 21 | .word 0x06186000, 0x00006018, 0x007E0000, 0x0000007E, 0x60180600, 0x00000618, 0x3060663C, 0x00180018 22 | .word 0x5A5A663C, 0x003C067A, 0x7E66663C, 0x00666666, 0x3E66663E, 0x003E6666, 0x06060C78, 0x00780C06 23 | .word 0x6666361E, 0x001E3666, 0x1E06067E, 0x007E0606, 0x1E06067E, 0x00060606, 0x7606663C, 0x007C6666 24 | .word 0x7E666666, 0x00666666, 0x1818183C, 0x003C1818, 0x60606060, 0x003C6660, 0x0F1B3363, 0x0063331B 25 | .word 0x06060606, 0x007E0606, 0x6B7F7763, 0x00636363, 0x7B6F6763, 0x00636373, 0x6666663C, 0x003C6666 26 | .word 0x3E66663E, 0x00060606, 0x3333331E, 0x007E3B33, 0x3E66663E, 0x00666636, 0x3C0E663C, 0x003C6670 27 | .word 0x1818187E, 0x00181818, 0x66666666, 0x003C6666, 0x66666666, 0x00183C3C, 0x6B636363, 0x0063777F 28 | .word 0x183C66C3, 0x00C3663C, 0x183C66C3, 0x00181818, 0x0C18307F, 0x007F0306, 0x0C0C0C3C, 0x003C0C0C 29 | .word 0x180C0603, 0x00C06030, 0x3030303C, 0x003C3030, 0x00663C18, 0x00000000, 0x00000000, 0x003F0000 30 | .word 0x00301818, 0x00000000, 0x603C0000, 0x007C667C, 0x663E0606, 0x003E6666, 0x063C0000, 0x003C0606 31 | .word 0x667C6060, 0x007C6666, 0x663C0000, 0x003C067E, 0x0C3E0C38, 0x000C0C0C, 0x667C0000, 0x3C607C66 32 | .word 0x663E0606, 0x00666666, 0x18180018, 0x00301818, 0x30300030, 0x1E303030, 0x36660606, 0x0066361E 33 | .word 0x18181818, 0x00301818, 0x7F370000, 0x0063636B, 0x663E0000, 0x00666666, 0x663C0000, 0x003C6666 34 | .word 0x663E0000, 0x06063E66, 0x667C0000, 0x60607C66, 0x663E0000, 0x00060606, 0x063C0000, 0x003E603C 35 | .word 0x0C3E0C0C, 0x00380C0C, 0x66660000, 0x007C6666, 0x66660000, 0x00183C66, 0x63630000, 0x00367F6B 36 | .word 0x36630000, 0x0063361C, 0x66660000, 0x0C183C66, 0x307E0000, 0x007E0C18, 0x0C181830, 0x00301818 37 | .word 0x18181818, 0x00181818, 0x3018180C, 0x000C1818, 0x003B6E00, 0x00000000, 0x00000000, 0x00000000 38 | 39 | font_tiles_end: 40 | 41 | 42 | 43 | font_tiles_size = font_tiles_end - font_tiles 44 | 45 | 46 | .arm 47 | .text 48 | 49 | /* 50 | void no args 51 | */ 52 | init_text: 53 | 54 | push {r0-r7} 55 | 56 | // dispcnt enable bg1 text mode 0 57 | mov r0, #0x04000000 58 | mov r1, #0x100 59 | strh r1, [r0] 60 | 61 | # bg1cnt 4bpp max priority 62 | # relocate bg map 63 | mov r1, #0x800 64 | strh r1, [r0,#0x8] 65 | 66 | # setup palette 67 | mov r0, #0x05000000 68 | // yeah i know we only use the bottom of this 69 | mov r1, #0xffffffff 70 | strh r1, [r0,#2] 71 | 72 | 73 | mov r0, #0x06000000 74 | ldr r1, =font_tiles_size 75 | ldr r2, =font_tiles 76 | 77 | 78 | // 1bpp packing to 4bpp 79 | // so take a byte and for each byte 80 | // unpack 2 bits into a nibble 81 | // store in vram 82 | 83 | tile_copy_loop: 84 | // load our tile data 85 | ldrb r3, [r2,r1] 86 | 87 | // we load two bits at a time out of this 88 | // so 4 instead of 8 89 | mov r4, #4 90 | 91 | # reset our reg we are decoding the data into 92 | mov r5, #0 93 | unpack_loop: 94 | // shift up our decoded data 95 | lsl r5, #8 96 | 97 | // load low nibble 98 | and r6, r3, #128 99 | lsr r6, #7 100 | lsl r3, #1 101 | lsl r6, #4 102 | 103 | // load high nibble 104 | and r7, r3, #128 105 | lsr r7, #7 106 | lsl r3, #1 107 | 108 | # combine current byte into word 109 | orr r6, r7 110 | orr r5, r6 111 | 112 | 113 | // if we still have data in the byte keep doing 114 | subs r4, #0x1 115 | bne unpack_loop 116 | 117 | // unpack is done our decoded 118 | // 4bpp tile should be in r4 119 | // need to *4 r0 as our output 120 | // is 4 times larger 121 | str r5, [r0,r1, lsl #0x2] 122 | 123 | 124 | subs r1, #1 125 | bne tile_copy_loop 126 | 127 | 128 | // reset our text counters 129 | // how to define this as a constant? 130 | mov r0, #0x02000000 131 | strb r1, [r0] // col 132 | strb r1, [r0,#1] // row 133 | 134 | pop {r0-r7} 135 | bx lr 136 | 137 | 138 | // r0: char to print 139 | // void return 140 | putchar: 141 | push {r0-r5} 142 | 143 | // get bg col and row 144 | mov r2, #0x02000000 145 | ldrb r3, [r2] 146 | ldrb r4, [r2,#1] 147 | 148 | // load bg map offset 149 | ldr r1, =#0x06004000 150 | 151 | // check for linefeed 152 | cmp r0, #0xa 153 | beq inc_row 154 | 155 | 156 | 157 | 158 | // if in the printable ascii range 159 | cmp r0, #0x20 160 | // ignore non printable chars 161 | blt putchar_end 162 | 163 | cmp r0, #0x7e 164 | bgt putchar_end 165 | 166 | // convert to printable range 167 | sub r0, #0x20 168 | 169 | 170 | // calc bg offset 171 | 172 | // calc col offset 173 | mov r5, r3, lsl #1 174 | 175 | // calc row offset 176 | add r5, r4, lsl #6 177 | 178 | 179 | 180 | // store the char 181 | strh r0, [r5,r1] 182 | 183 | // inc row and check we havent gone past screen size 184 | add r3, #1 185 | cmp r3, #30 186 | 187 | bne store_cords 188 | 189 | inc_row: 190 | // reset col and goto next row 191 | mov r3, #0 192 | add r4,#1 193 | 194 | // end of screen copy each one up 195 | cmp r4, #20 196 | bne store_cords 197 | 198 | // bg line size 199 | mov r2, #64 200 | 201 | // transfer limit 202 | add r3, r1, #0x500 203 | 204 | // r0 dst, r1 source 205 | mov r0, r1 206 | add r1, r2 207 | 208 | row_copy_loop: 209 | push {lr} 210 | bl memcpy 211 | pop {lr} 212 | 213 | // inc dst, src 214 | add r0, r2 215 | add r1, r2 216 | 217 | // if src is at line 20 we are done 218 | cmp r0, r3 219 | bne row_copy_loop 220 | 221 | // last line col zero 222 | mov r3, #0 223 | mov r4, #19 224 | mov r2, #0x02000000 225 | 226 | 227 | 228 | store_cords: 229 | strb r3, [r2] 230 | strb r4, [r2,#1] 231 | 232 | putchar_end: 233 | pop {r0-r5} 234 | bx lr 235 | 236 | 237 | // r0: pointer to string 238 | // void return 239 | write: 240 | push {r0-r1} 241 | 242 | mov r1, r0 243 | 244 | // while not zero putchar 245 | write_loop: 246 | ldrb r0, [r1], #1 247 | cmp r0, #0x0 248 | beq write_done 249 | push {lr} 250 | bl putchar 251 | pop {lr} 252 | b write_loop 253 | 254 | 255 | write_done: 256 | pop {r0-r1} 257 | bx lr 258 | 259 | 260 | 261 | 262 | // r0 number to print 263 | // void return 264 | print_hex: 265 | push {r0-r2} 266 | 267 | 268 | // get each nibble of the arg 269 | // and convert it to a char 270 | mov r1, r0 271 | 272 | mov r2, #8 273 | hex_loop: 274 | and r0, r1, #0xf0000000 275 | lsr r0, #28 276 | lsl r1, #4 277 | cmp r0, #9 278 | bgt conv_upper_hex 279 | // convert to a number 280 | add r0, #48 281 | b hex_printchar 282 | 283 | conv_upper_hex: 284 | // this now above ten so convert to 'a' - 'f' 285 | add r0, #55 286 | 287 | 288 | hex_printchar: 289 | push {lr} 290 | bl putchar 291 | pop {lr} 292 | 293 | subs r2, #1 294 | bne hex_loop 295 | 296 | pop {r0-r2} 297 | bx lr 298 | 299 | 300 | // need to these to handle bus limitations 301 | // otherwhise they will not copy properly 302 | 303 | 304 | 305 | // currently wont handle a odd transfer size... 306 | 307 | // r0 dest 308 | // r1 src 309 | // r2 size 310 | // void return 311 | memcpy: 312 | push {r2-r3} 313 | 314 | // ignore 0th bit 315 | mvn r3, #1 316 | and r2, r3 317 | memcpy_loop: 318 | ldrh r3, [r1,r2] 319 | strh r3, [r0,r2] 320 | subs r2, #2 321 | bne memcpy_loop 322 | 323 | pop {r2-r3} 324 | bx lr 325 | 326 | 327 | // r0 dest 328 | // r1 val 329 | // r2 size 330 | memset: 331 | push {r2} 332 | memset_loop: 333 | strb r1, [r0, r2] 334 | subs r2, #1 335 | bne memset_loop 336 | 337 | pop {r2} 338 | bx lr -------------------------------------------------------------------------------- /cond_invalid/source/text.s: -------------------------------------------------------------------------------- 1 | .global init_text 2 | .global putchar 3 | .global write 4 | .global print_hex 5 | 6 | 7 | .data 8 | 9 | // 1bpp encoding 10 | font_tiles: 11 | 12 | // font taken from https://www.coranac.com/tonc/text/text.htm 13 | 14 | .word 0x00000000, 0x00000000, 0x18181818, 0x00180018, 0x00003636, 0x00000000, 0x367F3636, 0x0036367F 15 | .word 0x3C067C18, 0x00183E60, 0x1B356600, 0x0033566C, 0x6E16361C, 0x00DE733B, 0x000C1818, 0x00000000 16 | .word 0x0C0C1830, 0x0030180C, 0x3030180C, 0x000C1830, 0xFF3C6600, 0x0000663C, 0x7E181800, 0x00001818 17 | .word 0x00000000, 0x0C181800, 0x7E000000, 0x00000000, 0x00000000, 0x00181800, 0x183060C0, 0x0003060C 18 | .word 0x7E76663C, 0x003C666E, 0x181E1C18, 0x00181818, 0x3060663C, 0x007E0C18, 0x3860663C, 0x003C6660 19 | .word 0x33363C38, 0x0030307F, 0x603E067E, 0x003C6660, 0x3E060C38, 0x003C6666, 0x3060607E, 0x00181818 20 | .word 0x3C66663C, 0x003C6666, 0x7C66663C, 0x001C3060, 0x00181800, 0x00181800, 0x00181800, 0x0C181800 21 | .word 0x06186000, 0x00006018, 0x007E0000, 0x0000007E, 0x60180600, 0x00000618, 0x3060663C, 0x00180018 22 | .word 0x5A5A663C, 0x003C067A, 0x7E66663C, 0x00666666, 0x3E66663E, 0x003E6666, 0x06060C78, 0x00780C06 23 | .word 0x6666361E, 0x001E3666, 0x1E06067E, 0x007E0606, 0x1E06067E, 0x00060606, 0x7606663C, 0x007C6666 24 | .word 0x7E666666, 0x00666666, 0x1818183C, 0x003C1818, 0x60606060, 0x003C6660, 0x0F1B3363, 0x0063331B 25 | .word 0x06060606, 0x007E0606, 0x6B7F7763, 0x00636363, 0x7B6F6763, 0x00636373, 0x6666663C, 0x003C6666 26 | .word 0x3E66663E, 0x00060606, 0x3333331E, 0x007E3B33, 0x3E66663E, 0x00666636, 0x3C0E663C, 0x003C6670 27 | .word 0x1818187E, 0x00181818, 0x66666666, 0x003C6666, 0x66666666, 0x00183C3C, 0x6B636363, 0x0063777F 28 | .word 0x183C66C3, 0x00C3663C, 0x183C66C3, 0x00181818, 0x0C18307F, 0x007F0306, 0x0C0C0C3C, 0x003C0C0C 29 | .word 0x180C0603, 0x00C06030, 0x3030303C, 0x003C3030, 0x00663C18, 0x00000000, 0x00000000, 0x003F0000 30 | .word 0x00301818, 0x00000000, 0x603C0000, 0x007C667C, 0x663E0606, 0x003E6666, 0x063C0000, 0x003C0606 31 | .word 0x667C6060, 0x007C6666, 0x663C0000, 0x003C067E, 0x0C3E0C38, 0x000C0C0C, 0x667C0000, 0x3C607C66 32 | .word 0x663E0606, 0x00666666, 0x18180018, 0x00301818, 0x30300030, 0x1E303030, 0x36660606, 0x0066361E 33 | .word 0x18181818, 0x00301818, 0x7F370000, 0x0063636B, 0x663E0000, 0x00666666, 0x663C0000, 0x003C6666 34 | .word 0x663E0000, 0x06063E66, 0x667C0000, 0x60607C66, 0x663E0000, 0x00060606, 0x063C0000, 0x003E603C 35 | .word 0x0C3E0C0C, 0x00380C0C, 0x66660000, 0x007C6666, 0x66660000, 0x00183C66, 0x63630000, 0x00367F6B 36 | .word 0x36630000, 0x0063361C, 0x66660000, 0x0C183C66, 0x307E0000, 0x007E0C18, 0x0C181830, 0x00301818 37 | .word 0x18181818, 0x00181818, 0x3018180C, 0x000C1818, 0x003B6E00, 0x00000000, 0x00000000, 0x00000000 38 | 39 | font_tiles_end: 40 | 41 | 42 | 43 | font_tiles_size = font_tiles_end - font_tiles 44 | 45 | 46 | .arm 47 | .text 48 | 49 | /* 50 | void no args 51 | */ 52 | init_text: 53 | 54 | push {r0-r7} 55 | 56 | // dispcnt enable bg1 text mode 0 57 | mov r0, #0x04000000 58 | mov r1, #0x100 59 | strh r1, [r0] 60 | 61 | # bg1cnt 4bpp max priority 62 | # relocate bg map 63 | mov r1, #0x800 64 | strh r1, [r0,#0x8] 65 | 66 | # setup palette 67 | mov r0, #0x05000000 68 | // yeah i know we only use the bottom of this 69 | mov r1, #0xffffffff 70 | strh r1, [r0,#2] 71 | 72 | 73 | mov r0, #0x06000000 74 | ldr r1, =font_tiles_size 75 | ldr r2, =font_tiles 76 | 77 | 78 | // 1bpp packing to 4bpp 79 | // so take a byte and for each byte 80 | // unpack 2 bits into a nibble 81 | // store in vram 82 | 83 | tile_copy_loop: 84 | // load our tile data 85 | ldrb r3, [r2,r1] 86 | 87 | // we load two bits at a time out of this 88 | // so 4 instead of 8 89 | mov r4, #4 90 | 91 | # reset our reg we are decoding the data into 92 | mov r5, #0 93 | unpack_loop: 94 | // shift up our decoded data 95 | lsl r5, #8 96 | 97 | // load low nibble 98 | and r6, r3, #128 99 | lsr r6, #7 100 | lsl r3, #1 101 | lsl r6, #4 102 | 103 | // load high nibble 104 | and r7, r3, #128 105 | lsr r7, #7 106 | lsl r3, #1 107 | 108 | # combine current byte into word 109 | orr r6, r7 110 | orr r5, r6 111 | 112 | 113 | // if we still have data in the byte keep doing 114 | subs r4, #0x1 115 | bne unpack_loop 116 | 117 | // unpack is done our decoded 118 | // 4bpp tile should be in r4 119 | // need to *4 r0 as our output 120 | // is 4 times larger 121 | str r5, [r0,r1, lsl #0x2] 122 | 123 | 124 | subs r1, #1 125 | bne tile_copy_loop 126 | 127 | 128 | // reset our text counters 129 | // how to define this as a constant? 130 | mov r0, #0x02000000 131 | strb r1, [r0] // col 132 | strb r1, [r0,#1] // row 133 | 134 | pop {r0-r7} 135 | bx lr 136 | 137 | 138 | // r0: char to print 139 | // void return 140 | putchar: 141 | push {r0-r5} 142 | 143 | // get bg col and row 144 | mov r2, #0x02000000 145 | ldrb r3, [r2] 146 | ldrb r4, [r2,#1] 147 | 148 | // load bg map offset 149 | ldr r1, =#0x06004000 150 | 151 | // check for linefeed 152 | cmp r0, #0xa 153 | beq inc_row 154 | 155 | 156 | 157 | 158 | // if in the printable ascii range 159 | cmp r0, #0x20 160 | // ignore non printable chars 161 | blt putchar_end 162 | 163 | cmp r0, #0x7e 164 | bgt putchar_end 165 | 166 | // convert to printable range 167 | sub r0, #0x20 168 | 169 | 170 | // calc bg offset 171 | 172 | // calc col offset 173 | mov r5, r3, lsl #1 174 | 175 | // calc row offset 176 | add r5, r4, lsl #6 177 | 178 | 179 | 180 | // store the char 181 | strh r0, [r5,r1] 182 | 183 | // inc row and check we havent gone past screen size 184 | add r3, #1 185 | cmp r3, #30 186 | 187 | bne store_cords 188 | 189 | inc_row: 190 | // reset col and goto next row 191 | mov r3, #0 192 | add r4,#1 193 | 194 | // end of screen copy each one up 195 | cmp r4, #20 196 | bne store_cords 197 | 198 | // bg line size 199 | mov r2, #64 200 | 201 | // transfer limit 202 | add r3, r1, #0x500 203 | 204 | // r0 dst, r1 source 205 | mov r0, r1 206 | add r1, r2 207 | 208 | row_copy_loop: 209 | push {lr} 210 | bl memcpy 211 | pop {lr} 212 | 213 | // inc dst, src 214 | add r0, r2 215 | add r1, r2 216 | 217 | // if src is at line 20 we are done 218 | cmp r0, r3 219 | bne row_copy_loop 220 | 221 | // last line col zero 222 | mov r3, #0 223 | mov r4, #19 224 | mov r2, #0x02000000 225 | 226 | 227 | 228 | store_cords: 229 | strb r3, [r2] 230 | strb r4, [r2,#1] 231 | 232 | putchar_end: 233 | pop {r0-r5} 234 | bx lr 235 | 236 | 237 | // r0: pointer to string 238 | // void return 239 | write: 240 | push {r0-r1} 241 | 242 | mov r1, r0 243 | 244 | // while not zero putchar 245 | write_loop: 246 | ldrb r0, [r1], #1 247 | cmp r0, #0x0 248 | beq write_done 249 | push {lr} 250 | bl putchar 251 | pop {lr} 252 | b write_loop 253 | 254 | 255 | write_done: 256 | pop {r0-r1} 257 | bx lr 258 | 259 | 260 | 261 | 262 | // r0 number to print 263 | // void return 264 | print_hex: 265 | push {r0-r2} 266 | 267 | 268 | // get each nibble of the arg 269 | // and convert it to a char 270 | mov r1, r0 271 | 272 | mov r2, #8 273 | hex_loop: 274 | and r0, r1, #0xf0000000 275 | lsr r0, #28 276 | lsl r1, #4 277 | cmp r0, #9 278 | bgt conv_upper_hex 279 | // convert to a number 280 | add r0, #48 281 | b hex_printchar 282 | 283 | conv_upper_hex: 284 | // this now above ten so convert to 'a' - 'f' 285 | add r0, #55 286 | 287 | 288 | hex_printchar: 289 | push {lr} 290 | bl putchar 291 | pop {lr} 292 | 293 | subs r2, #1 294 | bne hex_loop 295 | 296 | pop {r0-r2} 297 | bx lr 298 | 299 | 300 | // need to these to handle bus limitations 301 | // otherwhise they will not copy properly 302 | 303 | 304 | 305 | // currently wont handle a odd transfer size... 306 | 307 | // r0 dest 308 | // r1 src 309 | // r2 size 310 | // void return 311 | memcpy: 312 | push {r2-r3} 313 | 314 | // ignore 0th bit 315 | mvn r3, #1 316 | and r2, r3 317 | memcpy_loop: 318 | ldrh r3, [r1,r2] 319 | strh r3, [r0,r2] 320 | subs r2, #2 321 | bne memcpy_loop 322 | 323 | pop {r2-r3} 324 | bx lr 325 | 326 | 327 | // r0 dest 328 | // r1 val 329 | // r2 size 330 | memset: 331 | push {r2} 332 | memset_loop: 333 | strb r1, [r0, r2] 334 | subs r2, #1 335 | bne memset_loop 336 | 337 | pop {r2} 338 | bx lr -------------------------------------------------------------------------------- /dma_priority/source/text.s: -------------------------------------------------------------------------------- 1 | .global init_text 2 | .global putchar 3 | .global write 4 | .global print_hex 5 | 6 | 7 | .data 8 | 9 | // 1bpp encoding 10 | font_tiles: 11 | 12 | // font taken from https://www.coranac.com/tonc/text/text.htm 13 | 14 | .word 0x00000000, 0x00000000, 0x18181818, 0x00180018, 0x00003636, 0x00000000, 0x367F3636, 0x0036367F 15 | .word 0x3C067C18, 0x00183E60, 0x1B356600, 0x0033566C, 0x6E16361C, 0x00DE733B, 0x000C1818, 0x00000000 16 | .word 0x0C0C1830, 0x0030180C, 0x3030180C, 0x000C1830, 0xFF3C6600, 0x0000663C, 0x7E181800, 0x00001818 17 | .word 0x00000000, 0x0C181800, 0x7E000000, 0x00000000, 0x00000000, 0x00181800, 0x183060C0, 0x0003060C 18 | .word 0x7E76663C, 0x003C666E, 0x181E1C18, 0x00181818, 0x3060663C, 0x007E0C18, 0x3860663C, 0x003C6660 19 | .word 0x33363C38, 0x0030307F, 0x603E067E, 0x003C6660, 0x3E060C38, 0x003C6666, 0x3060607E, 0x00181818 20 | .word 0x3C66663C, 0x003C6666, 0x7C66663C, 0x001C3060, 0x00181800, 0x00181800, 0x00181800, 0x0C181800 21 | .word 0x06186000, 0x00006018, 0x007E0000, 0x0000007E, 0x60180600, 0x00000618, 0x3060663C, 0x00180018 22 | .word 0x5A5A663C, 0x003C067A, 0x7E66663C, 0x00666666, 0x3E66663E, 0x003E6666, 0x06060C78, 0x00780C06 23 | .word 0x6666361E, 0x001E3666, 0x1E06067E, 0x007E0606, 0x1E06067E, 0x00060606, 0x7606663C, 0x007C6666 24 | .word 0x7E666666, 0x00666666, 0x1818183C, 0x003C1818, 0x60606060, 0x003C6660, 0x0F1B3363, 0x0063331B 25 | .word 0x06060606, 0x007E0606, 0x6B7F7763, 0x00636363, 0x7B6F6763, 0x00636373, 0x6666663C, 0x003C6666 26 | .word 0x3E66663E, 0x00060606, 0x3333331E, 0x007E3B33, 0x3E66663E, 0x00666636, 0x3C0E663C, 0x003C6670 27 | .word 0x1818187E, 0x00181818, 0x66666666, 0x003C6666, 0x66666666, 0x00183C3C, 0x6B636363, 0x0063777F 28 | .word 0x183C66C3, 0x00C3663C, 0x183C66C3, 0x00181818, 0x0C18307F, 0x007F0306, 0x0C0C0C3C, 0x003C0C0C 29 | .word 0x180C0603, 0x00C06030, 0x3030303C, 0x003C3030, 0x00663C18, 0x00000000, 0x00000000, 0x003F0000 30 | .word 0x00301818, 0x00000000, 0x603C0000, 0x007C667C, 0x663E0606, 0x003E6666, 0x063C0000, 0x003C0606 31 | .word 0x667C6060, 0x007C6666, 0x663C0000, 0x003C067E, 0x0C3E0C38, 0x000C0C0C, 0x667C0000, 0x3C607C66 32 | .word 0x663E0606, 0x00666666, 0x18180018, 0x00301818, 0x30300030, 0x1E303030, 0x36660606, 0x0066361E 33 | .word 0x18181818, 0x00301818, 0x7F370000, 0x0063636B, 0x663E0000, 0x00666666, 0x663C0000, 0x003C6666 34 | .word 0x663E0000, 0x06063E66, 0x667C0000, 0x60607C66, 0x663E0000, 0x00060606, 0x063C0000, 0x003E603C 35 | .word 0x0C3E0C0C, 0x00380C0C, 0x66660000, 0x007C6666, 0x66660000, 0x00183C66, 0x63630000, 0x00367F6B 36 | .word 0x36630000, 0x0063361C, 0x66660000, 0x0C183C66, 0x307E0000, 0x007E0C18, 0x0C181830, 0x00301818 37 | .word 0x18181818, 0x00181818, 0x3018180C, 0x000C1818, 0x003B6E00, 0x00000000, 0x00000000, 0x00000000 38 | 39 | font_tiles_end: 40 | 41 | 42 | 43 | font_tiles_size = font_tiles_end - font_tiles 44 | 45 | 46 | .arm 47 | .text 48 | 49 | /* 50 | void no args 51 | */ 52 | init_text: 53 | 54 | push {r0-r7} 55 | 56 | // dispcnt enable bg1 text mode 0 57 | mov r0, #0x04000000 58 | mov r1, #0x100 59 | strh r1, [r0] 60 | 61 | # bg1cnt 4bpp max priority 62 | # relocate bg map 63 | mov r1, #0x800 64 | strh r1, [r0,#0x8] 65 | 66 | # setup palette 67 | mov r0, #0x05000000 68 | // yeah i know we only use the bottom of this 69 | mov r1, #0xffffffff 70 | strh r1, [r0,#2] 71 | 72 | 73 | mov r0, #0x06000000 74 | ldr r1, =font_tiles_size 75 | ldr r2, =font_tiles 76 | 77 | 78 | // 1bpp packing to 4bpp 79 | // so take a byte and for each byte 80 | // unpack 2 bits into a nibble 81 | // store in vram 82 | 83 | tile_copy_loop: 84 | // load our tile data 85 | ldrb r3, [r2,r1] 86 | 87 | // we load two bits at a time out of this 88 | // so 4 instead of 8 89 | mov r4, #4 90 | 91 | # reset our reg we are decoding the data into 92 | mov r5, #0 93 | unpack_loop: 94 | // shift up our decoded data 95 | lsl r5, #8 96 | 97 | // load low nibble 98 | and r6, r3, #128 99 | lsr r6, #7 100 | lsl r3, #1 101 | lsl r6, #4 102 | 103 | // load high nibble 104 | and r7, r3, #128 105 | lsr r7, #7 106 | lsl r3, #1 107 | 108 | # combine current byte into word 109 | orr r6, r7 110 | orr r5, r6 111 | 112 | 113 | // if we still have data in the byte keep doing 114 | subs r4, #0x1 115 | bne unpack_loop 116 | 117 | // unpack is done our decoded 118 | // 4bpp tile should be in r4 119 | // need to *4 r0 as our output 120 | // is 4 times larger 121 | str r5, [r0,r1, lsl #0x2] 122 | 123 | 124 | subs r1, #1 125 | bne tile_copy_loop 126 | 127 | 128 | // reset our text counters 129 | // how to define this as a constant? 130 | mov r0, #0x02000000 131 | strb r1, [r0] // col 132 | strb r1, [r0,#1] // row 133 | 134 | pop {r0-r7} 135 | bx lr 136 | 137 | 138 | // r0: char to print 139 | // void return 140 | putchar: 141 | push {r0-r5} 142 | 143 | // get bg col and row 144 | mov r2, #0x02000000 145 | ldrb r3, [r2] 146 | ldrb r4, [r2,#1] 147 | 148 | // load bg map offset 149 | ldr r1, =#0x06004000 150 | 151 | // check for linefeed 152 | cmp r0, #0xa 153 | beq inc_row 154 | 155 | 156 | 157 | 158 | // if in the printable ascii range 159 | cmp r0, #0x20 160 | // ignore non printable chars 161 | blt putchar_end 162 | 163 | cmp r0, #0x7e 164 | bgt putchar_end 165 | 166 | // convert to printable range 167 | sub r0, #0x20 168 | 169 | 170 | // calc bg offset 171 | 172 | // calc col offset 173 | mov r5, r3, lsl #1 174 | 175 | // calc row offset 176 | add r5, r4, lsl #6 177 | 178 | 179 | 180 | // store the char 181 | strh r0, [r5,r1] 182 | 183 | // inc row and check we havent gone past screen size 184 | add r3, #1 185 | cmp r3, #30 186 | 187 | bne store_cords 188 | 189 | inc_row: 190 | // reset col and goto next row 191 | mov r3, #0 192 | add r4,#1 193 | 194 | // end of screen copy each one up 195 | cmp r4, #20 196 | bne store_cords 197 | 198 | // bg line size 199 | mov r2, #64 200 | 201 | // transfer limit 202 | add r3, r1, #0x500 203 | 204 | // r0 dst, r1 source 205 | mov r0, r1 206 | add r1, r2 207 | 208 | row_copy_loop: 209 | push {lr} 210 | bl memcpy 211 | pop {lr} 212 | 213 | // inc dst, src 214 | add r0, r2 215 | add r1, r2 216 | 217 | // if src is at line 20 we are done 218 | cmp r0, r3 219 | bne row_copy_loop 220 | 221 | // last line col zero 222 | mov r3, #0 223 | mov r4, #19 224 | mov r2, #0x02000000 225 | 226 | 227 | 228 | store_cords: 229 | strb r3, [r2] 230 | strb r4, [r2,#1] 231 | 232 | putchar_end: 233 | pop {r0-r5} 234 | bx lr 235 | 236 | 237 | // r0: pointer to string 238 | // void return 239 | write: 240 | push {r0-r1} 241 | 242 | mov r1, r0 243 | 244 | // while not zero putchar 245 | write_loop: 246 | ldrb r0, [r1], #1 247 | cmp r0, #0x0 248 | beq write_done 249 | push {lr} 250 | bl putchar 251 | pop {lr} 252 | b write_loop 253 | 254 | 255 | write_done: 256 | pop {r0-r1} 257 | bx lr 258 | 259 | 260 | 261 | 262 | // r0 number to print 263 | // void return 264 | print_hex: 265 | push {r0-r2} 266 | 267 | 268 | // get each nibble of the arg 269 | // and convert it to a char 270 | mov r1, r0 271 | 272 | mov r2, #8 273 | hex_loop: 274 | and r0, r1, #0xf0000000 275 | lsr r0, #28 276 | lsl r1, #4 277 | cmp r0, #9 278 | bgt conv_upper_hex 279 | // convert to a number 280 | add r0, #48 281 | b hex_printchar 282 | 283 | conv_upper_hex: 284 | // this now above ten so convert to 'a' - 'f' 285 | add r0, #55 286 | 287 | 288 | hex_printchar: 289 | push {lr} 290 | bl putchar 291 | pop {lr} 292 | 293 | subs r2, #1 294 | bne hex_loop 295 | 296 | pop {r0-r2} 297 | bx lr 298 | 299 | 300 | // need to these to handle bus limitations 301 | // otherwhise they will not copy properly 302 | 303 | 304 | 305 | // currently wont handle a odd transfer size... 306 | 307 | // r0 dest 308 | // r1 src 309 | // r2 size 310 | // void return 311 | memcpy: 312 | push {r2-r3} 313 | 314 | // ignore 0th bit 315 | mvn r3, #1 316 | and r2, r3 317 | memcpy_loop: 318 | ldrh r3, [r1,r2] 319 | strh r3, [r0,r2] 320 | subs r2, #2 321 | bne memcpy_loop 322 | 323 | pop {r2-r3} 324 | bx lr 325 | 326 | 327 | // r0 dest 328 | // r1 val 329 | // r2 size 330 | memset: 331 | push {r2} 332 | memset_loop: 333 | strb r1, [r0, r2] 334 | subs r2, #1 335 | bne memset_loop 336 | 337 | pop {r2} 338 | bx lr -------------------------------------------------------------------------------- /hello_world/source/text.s: -------------------------------------------------------------------------------- 1 | .global init_text 2 | .global putchar 3 | .global write 4 | .global print_hex 5 | 6 | 7 | .data 8 | 9 | // 1bpp encoding 10 | font_tiles: 11 | 12 | // font taken from https://www.coranac.com/tonc/text/text.htm 13 | 14 | .word 0x00000000, 0x00000000, 0x18181818, 0x00180018, 0x00003636, 0x00000000, 0x367F3636, 0x0036367F 15 | .word 0x3C067C18, 0x00183E60, 0x1B356600, 0x0033566C, 0x6E16361C, 0x00DE733B, 0x000C1818, 0x00000000 16 | .word 0x0C0C1830, 0x0030180C, 0x3030180C, 0x000C1830, 0xFF3C6600, 0x0000663C, 0x7E181800, 0x00001818 17 | .word 0x00000000, 0x0C181800, 0x7E000000, 0x00000000, 0x00000000, 0x00181800, 0x183060C0, 0x0003060C 18 | .word 0x7E76663C, 0x003C666E, 0x181E1C18, 0x00181818, 0x3060663C, 0x007E0C18, 0x3860663C, 0x003C6660 19 | .word 0x33363C38, 0x0030307F, 0x603E067E, 0x003C6660, 0x3E060C38, 0x003C6666, 0x3060607E, 0x00181818 20 | .word 0x3C66663C, 0x003C6666, 0x7C66663C, 0x001C3060, 0x00181800, 0x00181800, 0x00181800, 0x0C181800 21 | .word 0x06186000, 0x00006018, 0x007E0000, 0x0000007E, 0x60180600, 0x00000618, 0x3060663C, 0x00180018 22 | .word 0x5A5A663C, 0x003C067A, 0x7E66663C, 0x00666666, 0x3E66663E, 0x003E6666, 0x06060C78, 0x00780C06 23 | .word 0x6666361E, 0x001E3666, 0x1E06067E, 0x007E0606, 0x1E06067E, 0x00060606, 0x7606663C, 0x007C6666 24 | .word 0x7E666666, 0x00666666, 0x1818183C, 0x003C1818, 0x60606060, 0x003C6660, 0x0F1B3363, 0x0063331B 25 | .word 0x06060606, 0x007E0606, 0x6B7F7763, 0x00636363, 0x7B6F6763, 0x00636373, 0x6666663C, 0x003C6666 26 | .word 0x3E66663E, 0x00060606, 0x3333331E, 0x007E3B33, 0x3E66663E, 0x00666636, 0x3C0E663C, 0x003C6670 27 | .word 0x1818187E, 0x00181818, 0x66666666, 0x003C6666, 0x66666666, 0x00183C3C, 0x6B636363, 0x0063777F 28 | .word 0x183C66C3, 0x00C3663C, 0x183C66C3, 0x00181818, 0x0C18307F, 0x007F0306, 0x0C0C0C3C, 0x003C0C0C 29 | .word 0x180C0603, 0x00C06030, 0x3030303C, 0x003C3030, 0x00663C18, 0x00000000, 0x00000000, 0x003F0000 30 | .word 0x00301818, 0x00000000, 0x603C0000, 0x007C667C, 0x663E0606, 0x003E6666, 0x063C0000, 0x003C0606 31 | .word 0x667C6060, 0x007C6666, 0x663C0000, 0x003C067E, 0x0C3E0C38, 0x000C0C0C, 0x667C0000, 0x3C607C66 32 | .word 0x663E0606, 0x00666666, 0x18180018, 0x00301818, 0x30300030, 0x1E303030, 0x36660606, 0x0066361E 33 | .word 0x18181818, 0x00301818, 0x7F370000, 0x0063636B, 0x663E0000, 0x00666666, 0x663C0000, 0x003C6666 34 | .word 0x663E0000, 0x06063E66, 0x667C0000, 0x60607C66, 0x663E0000, 0x00060606, 0x063C0000, 0x003E603C 35 | .word 0x0C3E0C0C, 0x00380C0C, 0x66660000, 0x007C6666, 0x66660000, 0x00183C66, 0x63630000, 0x00367F6B 36 | .word 0x36630000, 0x0063361C, 0x66660000, 0x0C183C66, 0x307E0000, 0x007E0C18, 0x0C181830, 0x00301818 37 | .word 0x18181818, 0x00181818, 0x3018180C, 0x000C1818, 0x003B6E00, 0x00000000, 0x00000000, 0x00000000 38 | 39 | font_tiles_end: 40 | 41 | 42 | 43 | font_tiles_size = font_tiles_end - font_tiles 44 | 45 | 46 | .arm 47 | .text 48 | 49 | /* 50 | void no args 51 | */ 52 | init_text: 53 | 54 | push {r0-r7} 55 | 56 | // dispcnt enable bg1 text mode 0 57 | mov r0, #0x04000000 58 | mov r1, #0x100 59 | strh r1, [r0] 60 | 61 | # bg1cnt 4bpp max priority 62 | # relocate bg map 63 | mov r1, #0x800 64 | strh r1, [r0,#0x8] 65 | 66 | # setup palette 67 | mov r0, #0x05000000 68 | // yeah i know we only use the bottom of this 69 | mov r1, #0xffffffff 70 | strh r1, [r0,#2] 71 | 72 | 73 | mov r0, #0x06000000 74 | ldr r1, =font_tiles_size 75 | ldr r2, =font_tiles 76 | 77 | 78 | // 1bpp packing to 4bpp 79 | // so take a byte and for each byte 80 | // unpack 2 bits into a nibble 81 | // store in vram 82 | 83 | tile_copy_loop: 84 | // load our tile data 85 | ldrb r3, [r2,r1] 86 | 87 | // we load two bits at a time out of this 88 | // so 4 instead of 8 89 | mov r4, #4 90 | 91 | # reset our reg we are decoding the data into 92 | mov r5, #0 93 | unpack_loop: 94 | // shift up our decoded data 95 | lsl r5, #8 96 | 97 | // load low nibble 98 | and r6, r3, #128 99 | lsr r6, #7 100 | lsl r3, #1 101 | lsl r6, #4 102 | 103 | // load high nibble 104 | and r7, r3, #128 105 | lsr r7, #7 106 | lsl r3, #1 107 | 108 | # combine current byte into word 109 | orr r6, r7 110 | orr r5, r6 111 | 112 | 113 | // if we still have data in the byte keep doing 114 | subs r4, #0x1 115 | bne unpack_loop 116 | 117 | // unpack is done our decoded 118 | // 4bpp tile should be in r4 119 | // need to *4 r0 as our output 120 | // is 4 times larger 121 | str r5, [r0,r1, lsl #0x2] 122 | 123 | 124 | subs r1, #1 125 | bne tile_copy_loop 126 | 127 | 128 | // reset our text counters 129 | // how to define this as a constant? 130 | mov r0, #0x02000000 131 | strb r1, [r0] // col 132 | strb r1, [r0,#1] // row 133 | 134 | pop {r0-r7} 135 | bx lr 136 | 137 | 138 | // r0: char to print 139 | // void return 140 | putchar: 141 | push {r0-r5} 142 | 143 | // get bg col and row 144 | mov r2, #0x02000000 145 | ldrb r3, [r2] 146 | ldrb r4, [r2,#1] 147 | 148 | // load bg map offset 149 | ldr r1, =#0x06004000 150 | 151 | // check for linefeed 152 | cmp r0, #0xa 153 | beq inc_row 154 | 155 | 156 | 157 | 158 | // if in the printable ascii range 159 | cmp r0, #0x20 160 | // ignore non printable chars 161 | blt putchar_end 162 | 163 | cmp r0, #0x7e 164 | bgt putchar_end 165 | 166 | // convert to printable range 167 | sub r0, #0x20 168 | 169 | 170 | // calc bg offset 171 | 172 | // calc col offset 173 | mov r5, r3, lsl #1 174 | 175 | // calc row offset 176 | add r5, r4, lsl #6 177 | 178 | 179 | 180 | // store the char 181 | strh r0, [r5,r1] 182 | 183 | // inc row and check we havent gone past screen size 184 | add r3, #1 185 | cmp r3, #30 186 | 187 | bne store_cords 188 | 189 | inc_row: 190 | // reset col and goto next row 191 | mov r3, #0 192 | add r4,#1 193 | 194 | // end of screen copy each one up 195 | cmp r4, #20 196 | bne store_cords 197 | 198 | // bg line size 199 | mov r2, #64 200 | 201 | // transfer limit 202 | add r3, r1, #0x500 203 | 204 | // r0 dst, r1 source 205 | mov r0, r1 206 | add r1, r2 207 | 208 | row_copy_loop: 209 | push {lr} 210 | bl memcpy 211 | pop {lr} 212 | 213 | // inc dst, src 214 | add r0, r2 215 | add r1, r2 216 | 217 | // if src is at line 20 we are done 218 | cmp r0, r3 219 | bne row_copy_loop 220 | 221 | // last line col zero 222 | mov r3, #0 223 | mov r4, #19 224 | mov r2, #0x02000000 225 | 226 | 227 | 228 | store_cords: 229 | strb r3, [r2] 230 | strb r4, [r2,#1] 231 | 232 | putchar_end: 233 | pop {r0-r5} 234 | bx lr 235 | 236 | 237 | // r0: pointer to string 238 | // void return 239 | write: 240 | push {r0-r1} 241 | 242 | mov r1, r0 243 | 244 | // while not zero putchar 245 | write_loop: 246 | ldrb r0, [r1], #1 247 | cmp r0, #0x0 248 | beq write_done 249 | push {lr} 250 | bl putchar 251 | pop {lr} 252 | b write_loop 253 | 254 | 255 | write_done: 256 | pop {r0-r1} 257 | bx lr 258 | 259 | 260 | 261 | 262 | // r0 number to print 263 | // void return 264 | print_hex: 265 | push {r0-r2} 266 | 267 | 268 | // get each nibble of the arg 269 | // and convert it to a char 270 | mov r1, r0 271 | 272 | mov r2, #8 273 | hex_loop: 274 | and r0, r1, #0xf0000000 275 | lsr r0, #28 276 | lsl r1, #4 277 | cmp r0, #9 278 | bgt conv_upper_hex 279 | // convert to a number 280 | add r0, #48 281 | b hex_printchar 282 | 283 | conv_upper_hex: 284 | // this now above ten so convert to 'a' - 'f' 285 | add r0, #55 286 | 287 | 288 | hex_printchar: 289 | push {lr} 290 | bl putchar 291 | pop {lr} 292 | 293 | subs r2, #1 294 | bne hex_loop 295 | 296 | pop {r0-r2} 297 | bx lr 298 | 299 | 300 | // need to these to handle bus limitations 301 | // otherwhise they will not copy properly 302 | 303 | 304 | 305 | // currently wont handle a odd transfer size... 306 | 307 | // r0 dest 308 | // r1 src 309 | // r2 size 310 | // void return 311 | memcpy: 312 | push {r2-r3} 313 | 314 | // ignore 0th bit 315 | mvn r3, #1 316 | and r2, r3 317 | memcpy_loop: 318 | ldrh r3, [r1,r2] 319 | strh r3, [r0,r2] 320 | subs r2, #2 321 | bne memcpy_loop 322 | 323 | pop {r2-r3} 324 | bx lr 325 | 326 | 327 | // r0 dest 328 | // r1 val 329 | // r2 size 330 | memset: 331 | push {r2} 332 | memset_loop: 333 | strb r1, [r0, r2] 334 | subs r2, #1 335 | bne memset_loop 336 | 337 | pop {r2} 338 | bx lr -------------------------------------------------------------------------------- /line_timing/source/text.s: -------------------------------------------------------------------------------- 1 | .global init_text 2 | .global putchar 3 | .global write 4 | .global print_hex 5 | 6 | 7 | .data 8 | 9 | // 1bpp encoding 10 | font_tiles: 11 | 12 | // font taken from https://www.coranac.com/tonc/text/text.htm 13 | 14 | .word 0x00000000, 0x00000000, 0x18181818, 0x00180018, 0x00003636, 0x00000000, 0x367F3636, 0x0036367F 15 | .word 0x3C067C18, 0x00183E60, 0x1B356600, 0x0033566C, 0x6E16361C, 0x00DE733B, 0x000C1818, 0x00000000 16 | .word 0x0C0C1830, 0x0030180C, 0x3030180C, 0x000C1830, 0xFF3C6600, 0x0000663C, 0x7E181800, 0x00001818 17 | .word 0x00000000, 0x0C181800, 0x7E000000, 0x00000000, 0x00000000, 0x00181800, 0x183060C0, 0x0003060C 18 | .word 0x7E76663C, 0x003C666E, 0x181E1C18, 0x00181818, 0x3060663C, 0x007E0C18, 0x3860663C, 0x003C6660 19 | .word 0x33363C38, 0x0030307F, 0x603E067E, 0x003C6660, 0x3E060C38, 0x003C6666, 0x3060607E, 0x00181818 20 | .word 0x3C66663C, 0x003C6666, 0x7C66663C, 0x001C3060, 0x00181800, 0x00181800, 0x00181800, 0x0C181800 21 | .word 0x06186000, 0x00006018, 0x007E0000, 0x0000007E, 0x60180600, 0x00000618, 0x3060663C, 0x00180018 22 | .word 0x5A5A663C, 0x003C067A, 0x7E66663C, 0x00666666, 0x3E66663E, 0x003E6666, 0x06060C78, 0x00780C06 23 | .word 0x6666361E, 0x001E3666, 0x1E06067E, 0x007E0606, 0x1E06067E, 0x00060606, 0x7606663C, 0x007C6666 24 | .word 0x7E666666, 0x00666666, 0x1818183C, 0x003C1818, 0x60606060, 0x003C6660, 0x0F1B3363, 0x0063331B 25 | .word 0x06060606, 0x007E0606, 0x6B7F7763, 0x00636363, 0x7B6F6763, 0x00636373, 0x6666663C, 0x003C6666 26 | .word 0x3E66663E, 0x00060606, 0x3333331E, 0x007E3B33, 0x3E66663E, 0x00666636, 0x3C0E663C, 0x003C6670 27 | .word 0x1818187E, 0x00181818, 0x66666666, 0x003C6666, 0x66666666, 0x00183C3C, 0x6B636363, 0x0063777F 28 | .word 0x183C66C3, 0x00C3663C, 0x183C66C3, 0x00181818, 0x0C18307F, 0x007F0306, 0x0C0C0C3C, 0x003C0C0C 29 | .word 0x180C0603, 0x00C06030, 0x3030303C, 0x003C3030, 0x00663C18, 0x00000000, 0x00000000, 0x003F0000 30 | .word 0x00301818, 0x00000000, 0x603C0000, 0x007C667C, 0x663E0606, 0x003E6666, 0x063C0000, 0x003C0606 31 | .word 0x667C6060, 0x007C6666, 0x663C0000, 0x003C067E, 0x0C3E0C38, 0x000C0C0C, 0x667C0000, 0x3C607C66 32 | .word 0x663E0606, 0x00666666, 0x18180018, 0x00301818, 0x30300030, 0x1E303030, 0x36660606, 0x0066361E 33 | .word 0x18181818, 0x00301818, 0x7F370000, 0x0063636B, 0x663E0000, 0x00666666, 0x663C0000, 0x003C6666 34 | .word 0x663E0000, 0x06063E66, 0x667C0000, 0x60607C66, 0x663E0000, 0x00060606, 0x063C0000, 0x003E603C 35 | .word 0x0C3E0C0C, 0x00380C0C, 0x66660000, 0x007C6666, 0x66660000, 0x00183C66, 0x63630000, 0x00367F6B 36 | .word 0x36630000, 0x0063361C, 0x66660000, 0x0C183C66, 0x307E0000, 0x007E0C18, 0x0C181830, 0x00301818 37 | .word 0x18181818, 0x00181818, 0x3018180C, 0x000C1818, 0x003B6E00, 0x00000000, 0x00000000, 0x00000000 38 | 39 | font_tiles_end: 40 | 41 | 42 | 43 | font_tiles_size = font_tiles_end - font_tiles 44 | 45 | 46 | .arm 47 | .text 48 | 49 | /* 50 | void no args 51 | */ 52 | init_text: 53 | 54 | push {r0-r7} 55 | 56 | // dispcnt enable bg1 text mode 0 57 | mov r0, #0x04000000 58 | mov r1, #0x100 59 | strh r1, [r0] 60 | 61 | # bg1cnt 4bpp max priority 62 | # relocate bg map 63 | mov r1, #0x800 64 | strh r1, [r0,#0x8] 65 | 66 | # setup palette 67 | mov r0, #0x05000000 68 | // yeah i know we only use the bottom of this 69 | mov r1, #0xffffffff 70 | strh r1, [r0,#2] 71 | 72 | 73 | mov r0, #0x06000000 74 | ldr r1, =font_tiles_size 75 | ldr r2, =font_tiles 76 | 77 | 78 | // 1bpp packing to 4bpp 79 | // so take a byte and for each byte 80 | // unpack 2 bits into a nibble 81 | // store in vram 82 | 83 | tile_copy_loop: 84 | // load our tile data 85 | ldrb r3, [r2,r1] 86 | 87 | // we load two bits at a time out of this 88 | // so 4 instead of 8 89 | mov r4, #4 90 | 91 | # reset our reg we are decoding the data into 92 | mov r5, #0 93 | unpack_loop: 94 | // shift up our decoded data 95 | lsl r5, #8 96 | 97 | // load low nibble 98 | and r6, r3, #128 99 | lsr r6, #7 100 | lsl r3, #1 101 | lsl r6, #4 102 | 103 | // load high nibble 104 | and r7, r3, #128 105 | lsr r7, #7 106 | lsl r3, #1 107 | 108 | # combine current byte into word 109 | orr r6, r7 110 | orr r5, r6 111 | 112 | 113 | // if we still have data in the byte keep doing 114 | subs r4, #0x1 115 | bne unpack_loop 116 | 117 | // unpack is done our decoded 118 | // 4bpp tile should be in r4 119 | // need to *4 r0 as our output 120 | // is 4 times larger 121 | str r5, [r0,r1, lsl #0x2] 122 | 123 | 124 | subs r1, #1 125 | bne tile_copy_loop 126 | 127 | 128 | // reset our text counters 129 | // how to define this as a constant? 130 | mov r0, #0x02000000 131 | strb r1, [r0] // col 132 | strb r1, [r0,#1] // row 133 | 134 | pop {r0-r7} 135 | bx lr 136 | 137 | 138 | // r0: char to print 139 | // void return 140 | putchar: 141 | push {r0-r5} 142 | 143 | // get bg col and row 144 | mov r2, #0x02000000 145 | ldrb r3, [r2] 146 | ldrb r4, [r2,#1] 147 | 148 | // load bg map offset 149 | ldr r1, =#0x06004000 150 | 151 | // check for linefeed 152 | cmp r0, #0xa 153 | beq inc_row 154 | 155 | 156 | 157 | 158 | // if in the printable ascii range 159 | cmp r0, #0x20 160 | // ignore non printable chars 161 | blt putchar_end 162 | 163 | cmp r0, #0x7e 164 | bgt putchar_end 165 | 166 | // convert to printable range 167 | sub r0, #0x20 168 | 169 | 170 | // calc bg offset 171 | 172 | // calc col offset 173 | mov r5, r3, lsl #1 174 | 175 | // calc row offset 176 | add r5, r4, lsl #6 177 | 178 | 179 | 180 | // store the char 181 | strh r0, [r5,r1] 182 | 183 | // inc row and check we havent gone past screen size 184 | add r3, #1 185 | cmp r3, #30 186 | 187 | bne store_cords 188 | 189 | inc_row: 190 | // reset col and goto next row 191 | mov r3, #0 192 | add r4,#1 193 | 194 | // end of screen copy each one up 195 | cmp r4, #20 196 | bne store_cords 197 | 198 | // bg line size 199 | mov r2, #64 200 | 201 | // transfer limit 202 | add r3, r1, #0x500 203 | 204 | // r0 dst, r1 source 205 | mov r0, r1 206 | add r1, r2 207 | 208 | row_copy_loop: 209 | push {lr} 210 | bl memcpy 211 | pop {lr} 212 | 213 | // inc dst, src 214 | add r0, r2 215 | add r1, r2 216 | 217 | // if src is at line 20 we are done 218 | cmp r0, r3 219 | bne row_copy_loop 220 | 221 | // last line col zero 222 | mov r3, #0 223 | mov r4, #19 224 | mov r2, #0x02000000 225 | 226 | 227 | 228 | store_cords: 229 | strb r3, [r2] 230 | strb r4, [r2,#1] 231 | 232 | putchar_end: 233 | pop {r0-r5} 234 | bx lr 235 | 236 | 237 | // r0: pointer to string 238 | // void return 239 | write: 240 | push {r0-r1} 241 | 242 | mov r1, r0 243 | 244 | // while not zero putchar 245 | write_loop: 246 | ldrb r0, [r1], #1 247 | cmp r0, #0x0 248 | beq write_done 249 | push {lr} 250 | bl putchar 251 | pop {lr} 252 | b write_loop 253 | 254 | 255 | write_done: 256 | pop {r0-r1} 257 | bx lr 258 | 259 | 260 | 261 | 262 | // r0 number to print 263 | // void return 264 | print_hex: 265 | push {r0-r2} 266 | 267 | 268 | // get each nibble of the arg 269 | // and convert it to a char 270 | mov r1, r0 271 | 272 | mov r2, #8 273 | hex_loop: 274 | and r0, r1, #0xf0000000 275 | lsr r0, #28 276 | lsl r1, #4 277 | cmp r0, #9 278 | bgt conv_upper_hex 279 | // convert to a number 280 | add r0, #48 281 | b hex_printchar 282 | 283 | conv_upper_hex: 284 | // this now above ten so convert to 'a' - 'f' 285 | add r0, #55 286 | 287 | 288 | hex_printchar: 289 | push {lr} 290 | bl putchar 291 | pop {lr} 292 | 293 | subs r2, #1 294 | bne hex_loop 295 | 296 | pop {r0-r2} 297 | bx lr 298 | 299 | 300 | // need to these to handle bus limitations 301 | // otherwhise they will not copy properly 302 | 303 | 304 | 305 | // currently wont handle a odd transfer size... 306 | 307 | // r0 dest 308 | // r1 src 309 | // r2 size 310 | // void return 311 | memcpy: 312 | push {r2-r3} 313 | 314 | // ignore 0th bit 315 | mvn r3, #1 316 | and r2, r3 317 | memcpy_loop: 318 | ldrh r3, [r1,r2] 319 | strh r3, [r0,r2] 320 | subs r2, #2 321 | bne memcpy_loop 322 | 323 | pop {r2-r3} 324 | bx lr 325 | 326 | 327 | // r0 dest 328 | // r1 val 329 | // r2 size 330 | memset: 331 | push {r2} 332 | memset_loop: 333 | strb r1, [r0, r2] 334 | subs r2, #1 335 | bne memset_loop 336 | 337 | pop {r2} 338 | bx lr --------------------------------------------------------------------------------