Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Levin Müller committed Nov 5, 2021
2 parents e86dfd0 + c6da1c9 commit 45ce71e
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 17 deletions.
15 changes: 2 additions & 13 deletions src/constants_settings.asm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ state_bits:

.eqv MAX_RULE 4 # min rule 1

.eqv MAX_OBJECT 2 # min is 1

.eqv MAX_TIME_DELAY 100000 # min is obviosly 0

#.eqv ALIVE 0xa0a397
Expand Down Expand Up @@ -87,15 +85,6 @@ settings:

.word 0xa0a397 # color of living cells # adress by 32

glider:
.word 0x00030003 # 16BIt height| 16 bit widht
.word 0x35800000 # expression of glider status 001|101|011 -> 3x3 cells needed

smiley:
.word 0x00080009
.word 0x3E20A530
.word 0x1A2CE504
.word 0x7c000000


.text

.include "objects.asm"
42 changes: 42 additions & 0 deletions src/objects.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

# i sorted this out now because this looks better and is easier to use




.data

.eqv MAX_OBJECT 4 # min is 1

glider:
.word 0x00030003 # 16BIt height| 16 bit widht
.word 0x35800000 # expression of glider status 001|101|011 -> 3x3 cells needed

smiley:
.word 0x00080009
.word 0x3E20A530
.word 0x1A2CE504
.word 0x7c000000


r_pent:
.word 0x00030003 # 16BIt height| 16 bit widht
.word 0x79000000 # Bitmuster 011110010 + filling 0

glider_gun:
.word 0x000b0026 # 16BIt height| 16 bit widht
.word 0 # first and last row empty (buffer for views)
.word 0x00000001
.word 0
.word 0x14000001
.word 0x81800600
.word 0x08860019
.word 0x80411800
.word 0x06011614
.word 0x00000410
.word 0x10000008
.word 0x80000000
.word 0x18000000
.word 0

.text
44 changes: 40 additions & 4 deletions src/user_question.asm
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,12 @@ question_object:

li t0, 2
beq a0, t0, smiley_object

li t0, 3
beq a0, t0, r_pent_object

li t0, 4
beq a0, t0, glider_gun_object


glider_object:
Expand All @@ -391,7 +397,16 @@ question_object:
la a3, smiley # load adress of object to print
j finished_question_object

r_pent_object:
la a3, r_pent # load adress of object to print
j finished_question_object

glider_gun_object:
la a3, glider_gun # load adress of object to print
j finished_question_object

finished_question_object:
la a4, invalid_object # in case the object is too huge
jal ra, question_object_pos # returning pos on a1;a2 # not using a3 there so i do not need to save it
jal ra, draw_object
#resetting t0|ra
Expand All @@ -410,6 +425,7 @@ question_object:

question_object_pos:
# input a3 adress of object
# input a4 with return adress if object is too huge
addi sp, sp, -28
sw s0, 0(sp)
sw s1, 4(sp)
Expand All @@ -428,16 +444,25 @@ question_object_pos:

la s0, settings # i need gamefield size and cell size
lw s1, 0(s0) # cell size
lw t3, 12(s0) # widht


lw t3, 16(s0) # height
sub t3, t3, s1 # last row|right edge cell
div t3, t3, s1 # max cells before edge
sub t3, t3, t1 # object cell height
bltz t3, invalid_object_size # in case object is too huge

lw t3, 12(s0) # widht
sub t3, t3, s1 # last row|right edge cell
div t3, t3, s1 # max cells before edge
sub t3, t3, t0 # input cells
bltz t3, invalid_object_size # in case object is too huge

la a0, ask_object_x_pos
li a7, 4
ecall

sub t3, t3, s1 # last row|right edge cell
div t3, t3, s1 # max cells before edge
sub t3, t3, t0 # input cells

mv a0, t3
jal ra, print
jal ra, print_new_line
Expand Down Expand Up @@ -497,6 +522,17 @@ question_object_pos:
lw ra, 24(sp)
addi sp, sp, 28
j invalid_input

invalid_object_size:
lw s0, 0(sp)
lw s1, 4(sp)
lw t0, 8(sp)
lw t1, 12(sp)
lw t2, 16(sp)
lw t3, 20(sp)
lw ra, 24(sp)
addi sp, sp, 28
jr a4


invalid_input:
Expand Down

0 comments on commit 45ce71e

Please sign in to comment.