Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - ElementCoder

Pages: [1] 2 3
1
Hello guys, it's been some time :) I'm no longer doing much with calculators, but I'm still programming quite a lot. Currently I'm building a telescope with some  class mates and I'm writing the software for its control. We use a Pi B+ to manage everything but since it doesn't have its own clock I figured I'd buy an RTC module. The project is almost due though so getting the Adafruit one for the Pi would have taken too long so I bought one at a local store, a DS1302 (http://www.okaphone.com/artikel.asp?id=472987, sorry for the dutch). It's originally for the Arduino I believe, but I followed this guide to use it with my Pi: http://raspberrypi.stackexchange.com/questions/12310/would-it-be-possible-to-use-the-ds1302-made-for-arduino

It now works in the sense that I can set the time and read from it, but I've encountered a major problem: the clock doesn't seem to "tick" when unplugged from the Pi. It remembers the time it had before disconnecting though, so I don't believe the battery is dead. In the datasheet I found http://datasheets.maximintegrated.com/en/ds/DS1302.pdf I found something about a clock halt flag, but I'm not sure if that's it or how to fix it.

Is anyone familiar with this (type of) clock and could help me fix it? It would greatly ease the user experience :)

2
Gaming Discussion / What game to pick?
« on: June 01, 2014, 05:03:35 pm »
So I purchased Mario Kart 8 recently and it comes with a free game. The games I can choose from are:
  • Nintendo Land
  • New Super Mario Bros U
  • Game & Wario
  • Pikmin 3
  • Windwaker HD
  • Sonic: Lost World
  • Mario & Sonic at the Olympic Wintergames (not gonna choose this :P)
  • Wii Party U
  • The Wonderful 101
  • Monster Hunter Tri Ultimate
I already have NL, NSMBU and Pikmin 3. The Windwaker HD looks interesting, but I already have the GC one. My real doubt is between Sonic and Monster Hunter. What would you guys pick?

3
Computer Programming / [Solved] Two body simulation
« on: May 12, 2014, 09:25:35 am »
I'm trying to make a two body simulation, but it doesn't seem to work :( Plotting x vs y should be circular or elliptical right? Am I choosing the wrong starting conditions or is my way of doing it just wrong?

Code: [Select]
#!/usr/bin/env python
'''
Two body simulation.

'''
from __future__ import division
import math
import matplotlib.pyplot as pyp
import numpy as np

# Gravitational constant (N*m^2*kg^-2)
G = 6.674e-11
# A giga year in seconds.
gyrts = math.pi * 1e7 * 1e9

def Fgrav(M, m, r):
    ''' Gravitational force of two bodies attracting each other.
    '''
    return -G * M * m / r**2
   
# Solar mass (kg)
M = 1.989e30
# Earth mass (kg)
m = 5.9721e24

# Initial conditions.
# Position (m).
x, y = 150e9, 0
X, Y = 0, 0

# Velocity (m/s).
vx, vy = 0, 30e3
Vx, Vy = 0, 0

time = 5*math.pi*1e7
t = 0
dt = 1000
xarr, yarr, rarr, tarr = [], [], [], []
while t < time:
    # Update the positions.
    x += vx * dt
    y += vy * dt
    # Calculate the separation vector.
    dx = x - X
    dy = y - Y
    r2 = dx*dx + dy*dy + 1e-4
    r = np.sqrt(r2)
    #print 'dx, dy: ', dx, dy
    # Calculate components of the gravitational force.
    fgrav_x = Fgrav(M, m, r) * dx / r
    fgrav_y = Fgrav(M, m, r) * dy / r
    #print 'Fgrav: ', fgrav_x, fgrav_y
    # Update the velocities.
    vx += (fgrav_x / m) * dt
    vy += (fgrav_y / m) * dt
    Vx += (fgrav_x / M) * dt
    Vy += (fgrav_y / M) * dt
    #print 'vx, vy: ', vx, vy
   
    X += Vx * dt
    Y += Vy * dt
   
    # Store all data.
    xarr.append(dx); yarr.append(dy); rarr.append(r)
    tarr.append(t)
   
    t += dt
   


fig, (ax1, ax2) = pyp.subplots(2, 'nom')
ax1.plot(xarr, yarr)
ax1.set_xlabel('$x$ (m)'); ax1.set_ylabel('$y$ (m)')
ax2.plot(tarr, rarr)
ax2.set_xlabel('$t$ (s)'); ax2.set_ylabel('$r$ (m)')
fig.tight_layout()

pyp.show()

Edit: Updated with non-broken code.

4
ASM / [ARM/Nspire] Drawing sprites
« on: February 01, 2014, 01:29:30 pm »
So I have the following piece of code which draws a sprite on the screen:
Code: [Select]
#include <os.h>
main: .global main
push {r4-r11, lr}
bl lcd_ingray
bl clrscr
ldr r0, =0xC0000010
ldr r0, [r0]
mov r2, #8
adr r1, sprite
add r0, #200 @ x
add r0, #SCREEN_WIDTH/2 * 80 @ y
draw:
ldr r3, [r1], #4
str r3, [r0]
add r0, #SCREEN_WIDTH/2
subs r2, #1
bne draw @ if there are lines left, draw the next one
bl wait_key_pressed
mov r0, #0
pop {r4-r11, pc}

sprite: .word 0x00000000, 0x00000000, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00000000, 0x00000000
This is probably a stupid question, but the problem I'm facing is that I can only use x coordinates that are a multiple of 4. What would I need to do to be able to use any number for the x coordinate?

5
Computer Usage and Setup Help / Scrolling acting up
« on: December 09, 2013, 01:25:38 pm »
Since about two days ago my laptop started acting a bit weird. Now and then it just scrolls to the top of the window and won't let me scroll down anymore. It's usually fixed by pressing the scroll lock button once or twice (which also happens to be the num lock button, so it's rather annoying) so I'm assuming it's a problem with scroll lock turning itself on automatically or something. I have no clue what this is or how to fix it.  :(

6
Other / Draw circuits
« on: November 25, 2013, 04:00:47 am »
Just found this on Kickstarter. I find it pretty awesome :)
http://www.kickstarter.com/projects/electroninks/circuit-scribe-draw-circuits-instantly

7
Other / New, old PCs; any ideas?
« on: November 12, 2013, 02:12:01 pm »
My school is getting rid of old PCs so I'm taking them whenever they appear. I'll be keeping a little list (I name them after galaxy clusters) of them and I'm wondering what to put them to use for (server is not an option since I'm not allowed to leave them on 24/7 or I'll have to pay bills as well). I was thinking of maybe (once there are more) hooking them up together and make a little cluster to do Blender stuff on or something.

Pandora

CPU: PentiumD @ 3.00GHz fried it :P
RAM: 4x 2GB DDR2 Kingston
GPU: nVidia 6600 (not sure which one yet)
HDD: Western Digital Caviar 80GB

Further it has a CD drive, floppy drive and room for 6 harddrives. A mindblowing collection of 4 images of the dismantling process are here: http://imgur.com/OKuJfKf&vhY0Q57#0 and http://imgur.com/jGDby9d,jH3JC37#0

8
Math and Science / Study of the Open Cluster NGC 188
« on: November 01, 2013, 03:58:28 pm »
I know it's not very calc related but it fits science and had some programming in Awk and Python :P
As some of you may have heard or seen I've had an observation project for my astronomy class. It has driven us crazy many times but finally it's finished and a report has been made. It's my first scientific report so if you read it, criticism is welcome :)
Without further ado:


Picture copyright by me .

https://dl.dropboxusercontent.com/u/24638666/Astronomy/Reports/ngc188.pdf

9
ASM / [ARM/Nspire] ElementCoder's ARM Scrapyard
« on: August 29, 2013, 02:03:04 pm »
Welcome to my scrapyard. I have not stopped with ARM, I'm just picking up real life again since my study's second year is about to start. Progress will be much slower and updates may become rare(r), so I guessed I'd post what I've done so far. It's not much and by far good, but maybe it's useful to somebody or something.

Hello World, delivered with the ndless SDK
Spoiler For Spoiler:
Code: [Select]
#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/8
draw4b:
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 syscalls
str: .asciz "1234567890123456789"
Checker pattern of 4x4 squares
Spoiler For Spoiler:
Code: [Select]
#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 times
draw_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}
Quick test with red, green and blue bars
Spoiler For Spoiler:
Code: [Select]
#include <os.h>

main: .global main
push {lr}
bl lcd_incolor
bl clrscr
ldr r0, =0xC0000010
ldr r0, [r0]
mov r3, #SCREEN_HEIGHT
draw_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 0xF800F800
green: .word 0x07E007E0
blue: .word 0x001F001F
Sprite drawing
Spoiler For Spoiler:
Code: [Select]
#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, #40
draw:
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, 0x00000000
sprite2: .word 0x00FFFF00, 0x00FFFF00, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0x00FFFF00, 0x00FFFF00
Keypress detection
Spoiler For Spoiler:
Code: [Select]
#include <os.h>
@ check http://hackspire.unsads.com/wiki/index.php/Keypads for keypad info
main: .global main
push {lr}
bl lcd_ingray
bl clrscr
ldr r0, =0x900E0010 @ keypad data address
check:
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 program
end:
mov r0, #0
pop {pc}
Stuff that resembles a program
Stone age text editor (most likely written terribly, can throw errors because of this)
Spoiler For Spoiler:
Code: [Select]
#include <os.h>

main: .global main
@ setup
push {r4-r11, lr}
bl lcd_ingray
bl clrscr
mov r11, #0
keycheck:
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 keycheck
draw:
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 keys
spacekey:
adr r0, off
ldr r1, [r0]
add r1, #4
str r1, [r0]
  
add r11, #4
bl wait_key_pressed
b keycheck
delkey:
@ 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 keycheck
enterkey:
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 keycheck
ctrlkey:
b end
end:
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_y

letter_a: .word 0xFF0FF0FF, 0xFF0FF0FF, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0
letter_b: .word 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0xFF0000F0, 0xFF0000F0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0
letter_c: .word 0x0F0000FF, 0x0F0000F0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0x0F0000F0, 0x0F0000FF
letter_d: .word 0xFF0F00F0, 0xFF0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0xFF0000F0
letter_e: .word 0x0F0000F0, 0x0F0000F0, 0xFFFF0FF0, 0xFF0000F0, 0xFF0000F0, 0xFFFF0FF0, 0x0F0000F0, 0x0F0000F0
letter_f: .word 0x0F0000F0, 0x0F0000F0, 0xFFFF0FF0, 0xFF0F00F0, 0xFF0F00F0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0
letter_g: .word 0x0F0000FF, 0x0F0000F0, 0xFFFF0FF0, 0xFFFF0FF0, 0x0F000FF0, 0x0F000FF0, 0x0FF00FF0, 0x0F0000FF
letter_h: .word 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0
letter_i: .word 0x0F0000F0, 0x0F0000F0, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0x0F0000F0, 0x0F0000F0
letter_j: .word 0x0F00F0FF, 0x0F00F0FF, 0x0FF0FFFF, 0x0FF0FFFF, 0x0FF0FFFF, 0x0FF00FF0, 0x0F0000F0, 0xFF0000FF
letter_k: .word 0x0FF00FF0, 0x0F000FF0, 0xFF000FF0, 0xFF0F00F0, 0xFF0F00F0, 0xFF000FF0, 0x0F000FF0, 0x0FF00FF0
letter_l: .word 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0x0F0000F0, 0x0F0000F0
letter_m: .word 0x0FFFFFF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0
letter_n: .word 0x0FF00FF0, 0x0FF000F0, 0x0F0000F0, 0x0F000FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0
letter_o: .word 0xFF0000FF, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0xFF0000FF
letter_p: .word 0xFF0F00F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0xFF0F00F0, 0xFFFF0FF0, 0xFFFF0FF0
letter_q: .word 0xFF0000FF, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF000F0, 0x0F000FF0, 0xFF0000F0, 0x0F0F00FF
letter_r: .word 0xFF0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0F0000F0, 0xFF0000F0, 0xFF000FF0, 0x0FF00FF0, 0x0FF00FF0
letter_s: .word 0x0F00F0FF, 0x0F0000F0, 0xFFFF0FF0, 0xFF0F00F0, 0x0F0000F0, 0x0FF0FFFF, 0x0F0000F0, 0x0F0000F0
letter_t: .word 0x0F0000F0, 0x0F0000F0, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF
letter_u: .word 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0
letter_v: .word 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0xFF0000FF, 0xFF0FF0FF
letter_w: .word 0x0FFFFFF0, 0x0FFFFFF0, 0x0FFFFFF0, 0x0FFFFFF0, 0x0F0FF0F0, 0x0F0FF0F0, 0x0FF00FF0, 0x0FF00FF0
letter_x: .word 0x0FF00FF0, 0x0FF00FF0, 0xFF0000FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0000FF, 0x0FF00FF0, 0x0FF00FF0
letter_y: .word 0x0FF00FF0, 0x0FF00FF0, 0xFFF00FFF, 0xFF0000FF, 0xFF00FFFF, 0xFF0FFFFF, 0xFF0F0FFF, 0xFFFF00FF
ALIGN letter_z: .word 0x0F0000F0, 0x0F00FFF0, 0xFF00FFF0, 0xFF00FFFF, 0xFF0FF0FF, 0x0FFF00FF, 0x0FFF00F0, 0x0F0000F0
off: .word 0

10
ASM / [ARM/Nspire] Inserting a new line in text
« on: August 20, 2013, 04:38:12 pm »
I've been trying to have some sort of text input with ARM now but I've hit a wall at this point. I've implemented enter/newline continuing at the same x position and also managed to get it back to the start of the line.
The problem I have is incorporating the delete/backspace functionality. The code below shows how I imagined it to go, but this makes enter act all funky and weird, offsetting the letters from the right by the amount of characters deleted.
When uncommenting the commented code in delkey the program will not even build, resulting in an error message "149: Error: invalid constant (408) after fixup".

Code:
Code: [Select]
#include <os.h>
 
main: .global main
@ setup
push {r4-r11, lr}
bl lcd_ingray
bl clrscr
mov r11, #0
keycheck:
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 keycheck
draw:
mov r2, #8
drawa:
ldr r1, [r0], #4
str r1, [r10], #SCREEN_WIDTH/2
subs r2, #1
bne drawa
bl wait_key_pressed
  
adr r0, off
ldr r1, [r0]
add r1, #4
str r1, [r0]
  
add r11, #4
b keycheck

@ handle special keys
spacekey:
adr r0, off
ldr r1, [r0]
add r1, #4
str r1, [r0]
  
add r11, #4
bl wait_key_pressed
b keycheck
delkey:
@ 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 keycheck
enterkey:
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 keycheck
ctrlkey:
b end
end:
mov r0, #0
pop {r4-r11, pc}
 
@ Sprites; pixels go lik 0x78563412 !!!!
letter_a: .word 0xFF0FF0FF, 0xFF0FF0FF, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0
letter_b: .word 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0xFF0F00F0, 0xFF0F00F0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0
letter_c: .word 0x0F0000FF, 0x0F0000F0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0x0F0000F0, 0x0F0000FF
letter_d: .word 0xFF0F00F0, 0xFF0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0xFF0000F0
letter_e: .word 0x0F0000F0, 0x0F0000F0, 0xFFFF0FF0, 0xFF0000F0, 0xFF0000F0, 0xFFFF0FF0, 0x0F0000F0, 0x0F0000F0
letter_f: .word 0x0F0000F0, 0x0F0000F0, 0xFFFF0FF0, 0xFF0F00F0, 0xFF0F00F0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0
letter_g: .word 0x0F0000FF, 0x0F0000F0, 0xFFFF0FF0, 0xFFFF0FF0, 0x0F000FF0, 0x0F000FF0, 0x0FF00FF0, 0x0F0000FF
letter_h: .word 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0
letter_i: .word 0x0F0000F0, 0x0F0000F0, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0x0F0000F0, 0x0F0000F0
letter_j: .word 0x0F00F0FF, 0x0F00F0FF, 0x0FF0FFFF, 0x0FF0FFFF, 0x0FF0FFFF, 0x0FF00FF0, 0x0F0000F0, 0xFF0000FF
letter_k: .word 0x0FF00FF0, 0x0F000FF0, 0xFF000FF0, 0xFF0F00F0, 0xFF0F00F0, 0xFF000FF0, 0x0F000FF0, 0x0FF00FF0
letter_l: .word 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0xFFFF0FF0, 0x0F0000F0, 0x0F0000F0
letter_m: .word 0x0FFFFFF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0
letter_n: .word 0x0FF00FF0, 0x0FF000F0, 0x0F0000F0, 0x0F000FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0
letter_o: .word 0xFF0000FF, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0xFF0000FF
letter_p: .word 0xFF0F00F0, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0xFF0F00F0, 0xFFFF0FF0, 0xFFFF0FF0
letter_q: .word 0xFF0000FF, 0x0F0000F0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF000F0, 0x0F000FF0, 0xFF0000F0, 0x0F0F00FF
letter_r: .word 0xFF0000F0, 0x0F0000F0, 0x0FF00FF0, 0x0F0000F0, 0xFF0000F0, 0xFF000FF0, 0x0FF00FF0, 0x0FF00FF0
letter_s: .word 0x0F00F0FF, 0x0F0000F0, 0xFFFF0FF0, 0xFF0F00F0, 0x0F0000F0, 0x0FF0FFFF, 0x0F0000F0, 0x0F0000F0
letter_t: .word 0x0F0000F0, 0x0F0000F0, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0FF0FF
letter_u: .word 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0F0000F0, 0x0F0000F0
letter_v: .word 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0x0FF00FF0, 0xFF0000FF, 0xFF0FF0FF
letter_w: .word 0x0FFFFFF0, 0x0FFFFFF0, 0x0FFFFFF0, 0x0FFFFFF0, 0x0F0FF0F0, 0x0F0FF0F0, 0x0FF00FF0, 0x0FF00FF0
letter_x: .word 0x0FF00FF0, 0x0FF00FF0, 0xFF0000FF, 0xFF0FF0FF, 0xFF0FF0FF, 0xFF0000FF, 0x0FF00FF0, 0x0FF00FF0
letter_y: .word 0x0FF00FF0, 0x0FF00FF0, 0xFFF00FFF, 0xFF0000FF, 0xFF00FFFF, 0xFF0FFFFF, 0xFF0F0FFF, 0xFFFF00FF
letter_z: .word 0x0F0000F0, 0x0F00FFF0, 0xFF00FFF0, 0xFF00FFFF, 0xFF0FF0FF, 0x0FFF00FF, 0x0FFF00F0, 0x0F0000F0
 
off: .word 0



11
ASM / [ARM] Problem with branches
« on: August 12, 2013, 01:29:30 pm »
I'm playing around a bit with keypresses and wanted to put something together with it. It's a very simple idea: detect a keypress, branch to the appropriate label, do your thing and branch back to the keypress detection loop. In my attempt below the ctrl key exits the program and the enter key branches to another part. My problem is that this branch stays, when it goes back to the keypress detection loop (at least I think it does), it keeps branching to the part where the enter key points to. Have I misunderstood something about ARM or am I doing something wrong codewise?

Code: [Select]
#include <os.h>
    main: .global main
            push {r4-r11, lr}
            bl lcd_ingray
            bl clrscr
            ldr r1, =0x900E0010
    keycheck:
            ldrh r2, [r1, #0]
            tst r2, #1 << 1
            bne enterkey
           
            ldrh r2, [r1, #14]
            tst r2, #1 << 9
            bne ctrlkey
           
            b keycheck
    @ handle various keypresses
    enterkey:
            b stuff
    ctrlkey:
            b end
    stuff:
            b keycheck
    end:
            mov r0, #0
            pop {r4-r11, pc}

12
TI-Nspire / Nspire assembly
« on: July 09, 2013, 05:49:17 am »
I want to take a dive in the deep and dark depths of the nspire and learn to do stuff with assembly. I figure the way to start would be to learn to work with ndless and C, but for assembly I have no clue where to start or even how.

13
Computer Programming / Eric4 IDE
« on: May 07, 2013, 03:57:59 pm »
I had eric set up on my windows pc, but lost it during a some maintenance. Now I'm trying to get it back, but I just don't know how anymore. Does anyone have a clear tutorial on what to do (like how to install sid, because there is no exe :()? Because I'm pretty lost and confused now  :'(

14
Web Programming and Design / [Solved]Alignment problem.
« on: April 28, 2013, 09:00:12 am »
I have a problem with the alignment of my elements. I want to have a centered area like on the omni homepage but without the side stuff. The problem i have is that it works fine if I turn off the float property, but then it slips behind the menu bar :(
All code can be found here: https://github.com/ElementCoder/astro

Edit: this is fixed now, I left out the float: left part and added <br style="clear: both;"/> below the div of the menubar.

15
Math and Science / Galactic Lecturehall
« on: April 09, 2013, 04:55:57 pm »

So I don't know if this thread will even live for more than a week, but I'll try to gather some simple yet fascinating (in my opinion at least) facts about astronomy and the universe. It'll probably (not yet) be very high level complicated stuff,  but that will come later. So yeah, if anyone has some questions you can always ask and I'll see if I can help you out (of course you can help too :P).
Note: throughout these derivations you may think "why is he doing that?" or "why does he discard that?". The reason is because we make a few simple assumptions that make our lives a whole lot easier. Stars, matter clouds and galaxies for example are all 'perfect spheres'; stars are only hydrogen (though that may vary depending on what I'm derivating / showing).

Gravitational Collapse:
Condition 1: The cloud is larger than its Jeans length
Spoiler For Jeans length for a 3 dimensional cloud:


Condition 2: The cloud is heavier than its Jeans mass

Orbital mechanics (simple):
Spoiler For Orbital Veloctiy:

Spoiler For Escape Velocity:


Pages: [1] 2 3