From 0ad45225f7ecb1a8a5ee6751e8f682d5966c2fd8 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 23 Dec 2016 21:42:49 +0100 Subject: Some changes that were lying around --- Makefile | 2 +- functions.cpp | 4 +-- tetris/engine.prn | 79 ++++++++++++++++++++++++++++++++++++++++++++++++------- tetris/io.prn | 6 ++--- tetris/tetris.prn | 5 ++-- 5 files changed, 79 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index ded4503..4edfcba 100644 --- a/Makefile +++ b/Makefile @@ -12,5 +12,5 @@ clean: remake: clean all postrun: $(OBJECTS) - g++ -Wall -O2 -std=c++11 -o postrun $(OBJECTS) + g++ $(CXXFLAGS) -o postrun $(OBJECTS) strip postrun diff --git a/functions.cpp b/functions.cpp index 91f6ba9..1d5d48e 100644 --- a/functions.cpp +++ b/functions.cpp @@ -253,8 +253,8 @@ unordered_map&,unordered_map e_cblock newcbp e_validcbp & if + newcbp "e_cblockpos" gstore + end + end + dup "l" = if + e_cblockpos 1 + "newcbp" store + e_cblockpos ntiles_x % ntiles_x 1 - < e_cblock newcbp e_validcbp & if + newcbp "e_cblockpos" gstore + end + end + dup "j" = if + e_cblock 8 % e_cblock 8 / 3 + 4 % 8 * + "newcb" store + newcb e_cblockpos e_validcbp if + newcb "e_cblock" gstore + end + end + dup "j" = if + e_cblock 8 % e_cblock 8 / 1 + 4 % 8 * + "newcb" store + newcb e_cblockpos e_validcbp if + newcb "e_cblock" gstore + end + end + pop +} + +@defun "e_sleep_userinput" { + sleep_time "timeout" store 1 while + 0 1 mkarrayp mkarray mkarray timeout sys_select + "timeout" store + pop pop + arrlen if + e_getuserinput + stackdump + end + pop + timeout end +} + +@defun "e_runloop" { + 0 "exitrunloop" store + exitrunloop ! while e_fullrender + + e_cblockpos dup ntiles_x % swap ntiles_x / + e_cblock dup 8 % swap 8 / + dup4 + b_drawblock + io_pos_after io_goto + #sleep_time sleep + e_sleep_userinput + b_undrawblock + + e_cblockpos ntiles_x + #new cblockpos dup e_cblock swap e_validcbp if "e_cblockpos" gstore @@ -172,6 +226,13 @@ mkarray "e_blockqueue" store #(rot<<3) + idx pop e_cblock e_cblockpos e_applyblock e_newcblock + e_cblock e_cblockpos e_validcbp ! if + 1 "exitrunloop" store + e_blockqueue e_cblock arrpushf "e_blockqueue" gstore + e_fullrender + io_pos_after io_goto + "GAME OVER!\n" print + end end - 1 end + exitrunloop ! end } diff --git a/tetris/io.prn b/tetris/io.prn index d749150..24fb4bb 100644 --- a/tetris/io.prn +++ b/tetris/io.prn @@ -5,13 +5,13 @@ } @defun "io_pos_windowend" { #puts: x y - ntiles_x tile_sizex * padding_x 2 * + origin_x + - ntiles_y tile_sizey * padding_y 2 * + origin_y + + ntiles_x padding_x 2 * + tile_sizex * origin_x + + ntiles_y padding_y 2 * + tile_sizey * origin_y + } @defun "io_pos_after" { #puts: x y 0 - ntiles_y tile_sizey * padding_y 2 * + 1 + + ntiles_y padding_y 2 * + tile_sizey * origin_y + } @defun "io_clearscreen" { diff --git a/tetris/tetris.prn b/tetris/tetris.prn index c11ec57..c324a10 100644 --- a/tetris/tetris.prn +++ b/tetris/tetris.prn @@ -7,7 +7,7 @@ #PARAMETERS 0 "origin_x" store 5 "origin_y" store -3 "padding_x" store +2 "padding_x" store 2 "padding_y" store 11 "ntiles_x" store 13 "ntiles_y" store @@ -21,4 +21,5 @@ e_init #e_test e_runloop -io_pos_after io_goto +e_teardown +#io_pos_after io_goto -- cgit v1.2.3-70-g09d2