0 Members and 1 Guest are viewing this topic.
#include <os.h>main: .global main @ this can be used to set a breakpoint @bkpt push {r3, lr} bl lcd_ingray bl clrscr adr r0, str @ call syscalls this way syscall(strlen) mov r3, #0 ldr r1, =0xC0000010 @ screen address ldr r1,[r1]draw_line: @ in grayscale mode, each 4-byte word represents 8 pixels mov r2, #SCREEN_WIDTH/8draw4b: str r3, [r1], #4 subs r2, #1 bne draw4b @ skip a line add r1, #SCREEN_WIDTH/2 subs r0, #1 bne draw_line @ call libndls functions with bl bl wait_key_pressed mov r0, #0 pop {r3, pc}@ dummy str to show syscallsstr: .asciz "1234567890123456789"
#include <os.h>main: .global main push {lr} bl lcd_ingray bl clrscr mov r0, #SCREEN_HEIGHT/4 @ each cube will be 4x4 ldr r3, =0x0000FFFF @ 4px black 4px white ldr r1, =0xC0000010 ldr r1, [r1]draw_line: @ in grayscale mode each 4-byte word represents 8 pixels mvn r3, r3 @ flip the colors mov r2, #SCREEN_WIDTH/8 * 4 @ draw 40 pieces of 8 pixels 4 timesdraw_4b: @ draw 4 bytes to the screen str r3, [r1], #4 subs r2, #1 bne draw_4b subs r0, #1 bne draw_line bl wait_key_pressed mov r0, #0 pop {pc}
#include <os.h>main: .global main push {lr} bl lcd_incolor bl clrscr ldr r0, =0xC0000010 ldr r0, [r0] mov r3, #SCREEN_HEIGHTdraw_line: mov r2, #SCREEN_WIDTH/2 draw4b: cmp r2, #160 ldreq r1, red cmp r2, #107 ldreq r1, green cmp r2, #53 ldreq r1, blue str r1, [r0], #4 subs r2, #1 bne draw4b subs r3, #1 bne draw_line bl wait_key_pressed mov r0, #0 pop {pc} red: .word 0xF800F800green: .word 0x07E007E0blue: .word 0x001F001F
#include <os.h>@ r0: screen address@ r2: counter@ r3: address of sprite address@@main: .global main push {r4-r11, lr} @ push link register on the stack bl lcd_ingray bl clrscr ldr r0, =0xC0000010 @ screen address ldr r0, [r0] @ put the address of the screen address in r0 mov r2, #8 @ counter adr r1, sprite @ store the address of sprite in r1 adr r4, sprite2 add r0, #200 add r0, #SCREEN_WIDTH/2 * 160 mov r5, #40draw: ldr r3, [r1], #4 @ load whatever is on the address contained in r1 in r3 @ r1 contains the address of sprite, so r3 will contain @ the nth word of sprite data str r3, [r0], #8 @ draw a line to the screen ldr r3, [r4], #4 str r3, [r0], #-8 add r0, #SCREEN_WIDTH/2 @ move to the next line subs r2, #1 @ counter count down bne draw @ if there are lines left, draw the next one bl wait_key_pressed mov r0, #0 pop {r4-r11, pc} @ return 0 and pop everything back sprite: .word 0x00000000, 0x00000000, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00000000, 0x00000000sprite2: .word 0x00FFFF00, 0x00FFFF00, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0x00FFFF00, 0x00FFFF00
#include <os.h>@ check http://hackspire.unsads.com/wiki/index.php/Keypads for keypad infomain: .global main push {lr} bl lcd_ingray bl clrscr ldr r0, =0x900E0010 @ keypad data addresscheck: ldrh r1, [r0, #14] @ load the first half word into r1 tst r1, #1 << 9 @ check for a keypress (ctrl here), a keypress clears a bit bne end @ if the bit is not cleared (no keypress) branch to check b check @ else end the programend: mov r0, #0 pop {pc}
#include <os.h>main: .global main @ setup push {r4-r11, lr} bl lcd_ingray bl clrscr mov r11, #0keycheck: ldr r10, =0xC0000010 ldr r10, [r10] add r10, r11 @ check for keypresses ldr r0, =0x900E0010 ldrh r1, [r0, #8] @ a key tst r1, #1 << 6 adrne r0, letter_a bne draw @ b key tst r1, #1 << 5 adrne r0, letter_b bne draw @ c key tst r1, #1 << 4 adrne r0, letter_c bne draw @ d key tst r1, #1 << 2 adrne r0, letter_d bne draw @ e key tst r1, #1 << 1 adrne r0, letter_e bne draw @ f key tst r1, #1 << 0 adrne r0, letter_f bne draw ldrh r1, [r0, #6] @ g key tst r1, #1 << 6 adrne r0, letter_g bne draw @ h key tst r1, #1 << 5 adrne r0, letter_h bne draw @ i key tst r1, #1 << 4 adrne r0, letter_i bne draw @ j key tst r1, #1 << 2 adrne r0, letter_j bne draw @ k key tst r1, #1 << 1 adrne r0, letter_k bne draw @ l key tst r1, #1 << 0 adrne r0, letter_l bne draw ldrh r1, [r0, #4] @ m key tst r1, #1 << 6 adrne r0, letter_m bne draw @ n key tst r1, #1 << 5 adrne r0, letter_n bne draw @ o key tst r1, #1 << 4 adrne r0, letter_o bne draw @ p key tst r1, #1 << 2 adrne r0, letter_p bne draw @ q key tst r1, #1 << 1 adrne r0, letter_q bne draw @ r key tst r1, #1 << 0 adrne r0, letter_r bne draw ldrh r1, [r0, #2] @ s key tst r1, #1 << 6 adrne r0, letter_s bne draw @ t key tst r1, #1 << 5 adrne r0, letter_t bne draw @ u key tst r1, #1 << 4 adrne r0, letter_u bne draw @ v key tst r1, #1 << 2 adrne r0, letter_v bne draw @ w key tst r1, #1 << 1 adrne r0, letter_w bne draw @ x key tst r1, #1 << 0 adrne r0, letter_x bne draw ldrh r1, [r0, #0] @ y key tst r1, #1 << 6 adrne r0, letter_y bne draw @ z key tst r1, #1 << 5 adrne r0, letter_z bne draw@ special keys @ space key ldrh r1, [r0, #0] tst r1, #1 << 4 bne spacekey @ enter key ldrh r1, [r0, #0] tst r1, #1 << 1 bne enterkey @ del key ldrh r1, [r0, #10] tst r1, #1 << 9 bne delkey @bne keycheck @ ctrl key ldrh r1, [r0, #14] tst r1, #1 << 9 bne ctrlkey b keycheckdraw: mov r2, #8 drawa: ldr r1, [r0], #4 str r1, [r10], #SCREEN_WIDTH/2 subs r2, #1 bne drawa adr r0, off ldr r1, [r0] add r1, #4 str r1, [r0] add r11, #4 bl wait_key_pressed b keycheck@ handle special keysspacekey: adr r0, off ldr r1, [r0] add r1, #4 str r1, [r0] add r11, #4 bl wait_key_pressed b keycheckdelkey: @ set the screen pointer back one step sub r10, #4 sub r11, #4 @ set the offset back one step adr r0, off ldr r1, [r0] cmp r1, #0 subne r1, #4 str r1, [r0] @ store emptyness at the characters place ldr r0, =0xFFFFFFFF mov r1, #8 drawdel: str r0, [r10] add r10 ,#SCREEN_WIDTH/2 subs r1, #1 bne drawdel bl wait_key_pressed b keycheckenterkey: ldr r0, =SCREEN_WIDTH/2 * 9 ldr r1, off sub r0, r1 add r11, r0 adr r0, off mov r1, #0 str r1, [r0] bl wait_key_pressed b keycheckctrlkey: b endend: mov r0, #0 pop {r4-r11, pc} @ Sprites; pixels go lik 0x78563412 !!!!@ for some reason letter_z only works if it is located above letter_yletter_a: .word 0xFF0FF0FF, 0xFF0FF0FF, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0letter_b: .word 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0xFF0000F0, 0xFF0000F0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0letter_c: .word 0x0F0000FF, 0x0F0000F0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0x0F0000F0, 0x0F0000FFletter_d: .word 0xFF0F00F0, 0xFF0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0xFF0000F0letter_e: .word 0x0F0000F0, 0x0F0000F0, 0xFFFF0FF0, 0xFF0000F0, 0xFF0000F0, 0xFFFF0FF0, 0x0F0000F0, 0x0F0000F0letter_f: .word 0x0F0000F0, 0x0F0000F0, 0xFFFF0FF0, 0xFF0F00F0, 0xFF0F00F0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0letter_g: .word 0x0F0000FF, 0x0F0000F0, 0xFFFF0FF0, 0xFFFF0FF0, 0x0F000FF0, 0x0F000FF0, 0x0FF00FF0, 0x0F0000FFletter_h: .word 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0letter_i: .word 0x0F0000F0, 0x0F0000F0, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0x0F0000F0, 0x0F0000F0letter_j: .word 0x0F00F0FF, 0x0F00F0FF, 0x0FF0FFFF, 0x0FF0FFFF, 0x0FF0FFFF, 0x0FF00FF0, 0x0F0000F0, 0xFF0000FFletter_k: .word 0x0FF00FF0, 0x0F000FF0, 0xFF000FF0, 0xFF0F00F0, 0xFF0F00F0, 0xFF000FF0, 0x0F000FF0, 0x0FF00FF0letter_l: .word 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0x0F0000F0, 0x0F0000F0letter_m: .word 0x0FFFFFF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0letter_n: .word 0x0FF00FF0, 0x0FF000F0, 0x0F0000F0, 0x0F000FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0letter_o: .word 0xFF0000FF, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0xFF0000FFletter_p: .word 0xFF0F00F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0xFF0F00F0, 0xFFFF0FF0, 0xFFFF0FF0letter_q: .word 0xFF0000FF, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF000F0, 0x0F000FF0, 0xFF0000F0, 0x0F0F00FFletter_r: .word 0xFF0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0F0000F0, 0xFF0000F0, 0xFF000FF0, 0x0FF00FF0, 0x0FF00FF0letter_s: .word 0x0F00F0FF, 0x0F0000F0, 0xFFFF0FF0, 0xFF0F00F0, 0x0F0000F0, 0x0FF0FFFF, 0x0F0000F0, 0x0F0000F0letter_t: .word 0x0F0000F0, 0x0F0000F0, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FFletter_u: .word 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0letter_v: .word 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0xFF0000FF, 0xFF0FF0FFletter_w: .word 0x0FFFFFF0, 0x0FFFFFF0, 0x0FFFFFF0, 0x0FFFFFF0, 0x0F0FF0F0, 0x0F0FF0F0, 0x0FF00FF0, 0x0FF00FF0letter_x: .word 0x0FF00FF0, 0x0FF00FF0, 0xFF0000FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0000FF, 0x0FF00FF0, 0x0FF00FF0letter_y: .word 0x0FF00FF0, 0x0FF00FF0, 0xFFF00FFF, 0xFF0000FF, 0xFF00FFFF, 0xFF0FFFFF, 0xFF0F0FFF, 0xFFFF00FFALIGN letter_z: .word 0x0F0000F0, 0x0F00FFF0, 0xFF00FFF0, 0xFF00FFFF, 0xFF0FF0FF, 0x0FFF00FF, 0x0FFF00F0, 0x0F0000F0off: .word 0