0 Members and 2 Guests are viewing this topic.
/BrownyTCat's test prog#include <os.h>#include "utils.h"#include "keys.h"#define MAX_ITER 16asm(".string \"PRG\"\n");int main(void) {int i;int lose = 0;int playerX = 160;int playerY = 100;showSimpleDialogBox( "Ndless - Test Software", "-------------------------------\n" "Ndless C Demo\n" "Copyright 2010 by BrownyTCat\n" "-------------------------------\n" "ESC - Exit" ); for (i = 0; i < 0x0F; ++i) { fade(1); WAIT("0x1FFFFF", "fade"); } while (lose != 1 && !isKeyEscPressed()) { setPixel(playerX,playerY,16) ;if (isKeyUpPressed()) { setPixel(playerX,playerY,0) ;playerY = playerY - 1 ;} else if (isKeyDownPressed()) { setPixel(playerX,playerY,0) ;playerY = playerY + 1 ;} else if (isKeyLeftPressed()) { setPixel(playerX,playerY,0) ;playerX = playerX - 1 ;} else if (isKeyRightPressed()) { setPixel(playerX,playerY,0) ;playerX = playerX + 1 ;} } return 0;}
setPixel's third argument only goes up to 15; therefore, 16 will crash.
int isKeyEscPressed();int isKeyCtrlPressed();int isKeyMajPressed();int isKeyEnterPressed();int isKeyLeftPressed();int isKeyRightPressed();int isKeyUpPressed();int isKeyDownPressed();
asm(".macro is_key_pressed row, column");asm("ldr r0, =(0x900E0000 + \\row )");asm("ldrh r0, [r0]");asm("tst r0, \\column");asm(".endm");int isKeyEscPressed(){ asm("is_key_pressed 0x1c, #0b00010000000"); asm("movne r0, #0x0"); asm("moveq r0, #0x1");}int isKeyCtrlPressed(){ asm("is_key_pressed 0x1e, #0b001000000000"); asm("movne r0, #0x0"); asm("moveq r0, #0x1");}int isKeyMajPressed(){ asm("is_key_pressed 0x1a, #0b001000000000"); asm("movne r0, #0x0"); asm("moveq r0, #0x1");}int isKeyEnterPressed(){ asm("is_key_pressed 0x10, #0b000000000010"); asm("movne r0, #0x0"); asm("moveq r0, #0x1");}int isKeyLeftPressed(){ asm("is_key_pressed 0x1e, #0b000001000000"); asm("movne r0, #0x0"); asm("moveq r0, #0x1");}int isKeyRightPressed(){ asm("is_key_pressed 0x1e, #0b000000000100"); asm("movne r0, #0x0"); asm("moveq r0, #0x1");}int isKeyUpPressed(){ asm("is_key_pressed 0x1e, #0b000000000001"); asm("movne r0, #0x0"); asm("moveq r0, #0x1");}int isKeyDownPressed(){ asm("is_key_pressed 0x1e, #0b000000010000"); asm("movne r0, #0x0"); asm("moveq r0, #0x1");}