this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Cleanup: remove all trailing spaces from the source code (#2664)

* `cmake`: Remove trailing spaces

* `build`, `src`: Remove trailing spaces

* `templates`: Remove trailing spaces

* `demos`: Remove trailing spaces

* `include`: Remove trailing spaces

authored by

Alice and committed by
GitHub
81de993d e60a708b

+1186 -1186
+1 -1
build/rpi/toolchain.cmake
··· 9 9 set(CMAKE_C_COMPILER /usr/bin/${CMAKE_LIBRARY_ARCHITECTURE}-gcc-8) 10 10 set(CMAKE_CXX_COMPILER /usr/bin/${CMAKE_LIBRARY_ARCHITECTURE}-g++-8) 11 11 12 - # Define the sysroot path for the RaspberryPi distribution in our tools folder 12 + # Define the sysroot path for the RaspberryPi distribution in our tools folder 13 13 set(CMAKE_FIND_ROOT_PATH ${SYSROOT_PATH}) 14 14 15 15 # Use our definitions for compiler tools
+1 -1
build/tools/bin2txt.c
··· 68 68 memcpy(buffer, output, size); 69 69 } 70 70 71 - free(output); 71 + free(output); 72 72 } 73 73 else printf("memory error :(\n"); 74 74 }
+3 -3
cmake/core.cmake
··· 6 6 add_library(dlfcn STATIC ${THIRDPARTY_DIR}/dlfcn/src/dlfcn.c) 7 7 8 8 target_include_directories(dlfcn 9 - INTERFACE 10 - ${THIRDPARTY_DIR}/dirent/include 9 + INTERFACE 10 + ${THIRDPARTY_DIR}/dirent/include 11 11 ${THIRDPARTY_DIR}/dlfcn/src) 12 12 endif() 13 13 ··· 73 73 if(BUILD_WITH_FENNEL) 74 74 target_link_libraries(tic80core PRIVATE fennel) 75 75 endif() 76 - 76 + 77 77 if(BUILD_WITH_JS) 78 78 target_link_libraries(tic80core PRIVATE js) 79 79 endif()
+2 -2
cmake/fennel.cmake
··· 16 16 endif() 17 17 18 18 target_link_libraries(fennel PRIVATE runtime luaapi) 19 - target_include_directories(fennel 20 - PRIVATE 19 + target_include_directories(fennel 20 + PRIVATE 21 21 ${THIRDPARTY_DIR}/fennel 22 22 ${CMAKE_SOURCE_DIR}/include 23 23 ${CMAKE_SOURCE_DIR}/src
+2 -2
cmake/gif.cmake
··· 15 15 add_library(giflib STATIC ${GIFLIB_SRC}) 16 16 target_include_directories(giflib 17 17 PRIVATE ${GIFLIB_DIR} 18 - INTERFACE 19 - ${THIRDPARTY_DIR}/giflib 18 + INTERFACE 19 + ${THIRDPARTY_DIR}/giflib 20 20 ${THIRDPARTY_DIR}/msf_gif)
+3 -3
cmake/janet.cmake
··· 35 35 ) 36 36 endif() 37 37 38 - set(JANET_SRC 38 + set(JANET_SRC 39 39 ${THIRDPARTY_DIR}/janet/build/c/janet.c 40 40 ${CMAKE_SOURCE_DIR}/src/api/janet.c 41 41 ${CMAKE_SOURCE_DIR}/src/api/parse_note.c ··· 51 51 52 52 target_link_libraries(janet PRIVATE runtime) 53 53 54 - target_include_directories(janet 55 - PRIVATE 54 + target_include_directories(janet 55 + PRIVATE 56 56 ${THIRDPARTY_DIR}/janet/src/include 57 57 ${CMAKE_SOURCE_DIR}/build/janet 58 58 ${CMAKE_SOURCE_DIR}/include
+4 -4
cmake/lua.cmake
··· 43 43 ${LUA_DIR}/lbitlib.c 44 44 ) 45 45 46 - add_library(luaapi STATIC 46 + add_library(luaapi STATIC 47 47 ${LUA_SRC} 48 48 ${CMAKE_SOURCE_DIR}/src/api/luaapi.c 49 49 ${CMAKE_SOURCE_DIR}/src/api/parse_note.c ··· 51 51 52 52 target_compile_definitions(luaapi PRIVATE LUA_COMPAT_5_2) 53 53 54 - target_include_directories(luaapi 54 + target_include_directories(luaapi 55 55 PUBLIC ${THIRDPARTY_DIR}/lua 56 56 ${CMAKE_SOURCE_DIR}/include 57 57 ${CMAKE_SOURCE_DIR}/src ··· 71 71 72 72 target_link_libraries(lua PRIVATE runtime luaapi) 73 73 74 - target_include_directories(lua 74 + target_include_directories(lua 75 75 PUBLIC ${THIRDPARTY_DIR}/lua 76 - PRIVATE 76 + PRIVATE 77 77 ${CMAKE_SOURCE_DIR}/include 78 78 ${CMAKE_SOURCE_DIR}/src 79 79 )
+1 -1
cmake/moon.cmake
··· 30 30 target_link_libraries(moon PRIVATE lpeg runtime luaapi) 31 31 32 32 target_include_directories(moon 33 - PRIVATE 33 + PRIVATE 34 34 ${THIRDPARTY_DIR}/moonscript 35 35 ${CMAKE_SOURCE_DIR}/include 36 36 ${CMAKE_SOURCE_DIR}/src
+2 -2
cmake/mruby.cmake
··· 36 36 endif() 37 37 set(MRUBY_LIB ${MRUBY_DIR}/build/target/lib/libmruby.a) 38 38 39 - target_include_directories(ruby 39 + target_include_directories(ruby 40 40 PUBLIC ${MRUBY_DIR}/include 41 - PRIVATE 41 + PRIVATE 42 42 ${CMAKE_SOURCE_DIR}/include 43 43 ${CMAKE_SOURCE_DIR}/src 44 44 )
+3 -3
cmake/pocketpy.cmake
··· 13 13 target_compile_options(pocketpy PRIVATE -Wno-psabi) 14 14 endif() 15 15 16 - set(PYTHON_SRC 16 + set(PYTHON_SRC 17 17 ${CMAKE_SOURCE_DIR}/src/api/python.c 18 18 ${CMAKE_SOURCE_DIR}/src/api/parse_note.c 19 19 ) ··· 28 28 29 29 target_link_libraries(python PRIVATE runtime) 30 30 31 - target_include_directories(python 32 - PRIVATE 31 + target_include_directories(python 32 + PRIVATE 33 33 ${THIRDPARTY_DIR}/pocketpy/include 34 34 ${CMAKE_SOURCE_DIR}/include 35 35 ${CMAKE_SOURCE_DIR}/src
+6 -6
cmake/quickjs.cmake
··· 12 12 file(STRINGS ${QUICKJS_DIR}/VERSION CONFIG_VERSION) 13 13 14 14 set(QUICKJS_SRC 15 - ${QUICKJS_DIR}/quickjs.c 16 - ${QUICKJS_DIR}/libregexp.c 15 + ${QUICKJS_DIR}/quickjs.c 16 + ${QUICKJS_DIR}/libregexp.c 17 17 ${QUICKJS_DIR}/libunicode.c 18 18 ${QUICKJS_DIR}/cutils.c 19 19 ) ··· 26 26 endif() 27 27 28 28 if(BAREMETALPI OR N3DS) 29 - target_compile_definitions(quickjs PRIVATE POOR_CLIB) 29 + target_compile_definitions(quickjs PRIVATE POOR_CLIB) 30 30 endif() 31 31 32 32 if(LINUX) 33 33 target_compile_definitions(quickjs PUBLIC _GNU_SOURCE _POSIX_C_SOURCE=200112) 34 34 target_link_libraries(quickjs PUBLIC m dl pthread) 35 35 endif() 36 - 36 + 37 37 set(JS_SRC 38 38 ${CMAKE_SOURCE_DIR}/src/api/js.c 39 39 ${CMAKE_SOURCE_DIR}/src/api/parse_note.c ··· 50 50 target_link_libraries(js PRIVATE runtime) 51 51 52 52 target_link_libraries(js PRIVATE quickjs) 53 - target_include_directories(js 54 - PRIVATE 53 + target_include_directories(js 54 + PRIVATE 55 55 ${QUICKJS_DIR} 56 56 ${CMAKE_SOURCE_DIR}/include 57 57 ${CMAKE_SOURCE_DIR}/src
+2 -2
cmake/scheme.cmake
··· 23 23 target_link_libraries(scheme PRIVATE runtime) 24 24 25 25 set_target_properties(scheme PROPERTIES LINKER_LANGUAGE CXX) 26 - target_include_directories(scheme 26 + target_include_directories(scheme 27 27 PUBLIC ${SCHEME_DIR} 28 - PRIVATE 28 + PRIVATE 29 29 ${CMAKE_SOURCE_DIR}/include 30 30 ${CMAKE_SOURCE_DIR}/src 31 31 )
+2 -2
cmake/squirrel.cmake
··· 47 47 48 48 set_target_properties(squirrel PROPERTIES LINKER_LANGUAGE CXX) 49 49 50 - target_include_directories(squirrel 50 + target_include_directories(squirrel 51 51 PUBLIC ${SQUIRREL_DIR}/include 52 - PRIVATE 52 + PRIVATE 53 53 ${SQUIRREL_DIR}/squirrel 54 54 ${SQUIRREL_DIR}/sqstdlib 55 55 ${CMAKE_SOURCE_DIR}/include
+3 -3
cmake/studio.cmake
··· 16 16 ) 17 17 18 18 if(BUILD_EDITORS) 19 - set(TIC80STUDIO_SRC ${TIC80STUDIO_SRC} 19 + set(TIC80STUDIO_SRC ${TIC80STUDIO_SRC} 20 20 ${TIC80LIB_DIR}/studio/screens/console.c 21 21 ${TIC80LIB_DIR}/studio/screens/surf.c 22 22 ${TIC80LIB_DIR}/studio/editors/code.c ··· 33 33 endif() 34 34 35 35 if(BUILD_PRO) 36 - set(TIC80STUDIO_SRC ${TIC80STUDIO_SRC} 36 + set(TIC80STUDIO_SRC ${TIC80STUDIO_SRC} 37 37 ${TIC80LIB_DIR}/studio/project.c) 38 38 endif() 39 39 ··· 43 43 ${TIC80STUDIO_SRC} 44 44 ${CMAKE_SOURCE_DIR}/build/assets/cart.png.dat) 45 45 46 - target_include_directories(tic80studio 46 + target_include_directories(tic80studio 47 47 PRIVATE ${THIRDPARTY_DIR}/jsmn 48 48 PUBLIC ${CMAKE_CURRENT_BINARY_DIR} 49 49 )
+2 -2
cmake/wasm.cmake
··· 34 34 35 35 target_link_libraries(wasm PRIVATE runtime) 36 36 37 - target_include_directories(wasm 37 + target_include_directories(wasm 38 38 PUBLIC ${WASM_DIR} 39 - PRIVATE 39 + PRIVATE 40 40 ${CMAKE_SOURCE_DIR}/include 41 41 ${CMAKE_SOURCE_DIR}/src 42 42 )
+2 -2
cmake/wren.cmake
··· 33 33 34 34 target_link_libraries(wren PRIVATE runtime) 35 35 36 - target_include_directories(wren 37 - PRIVATE 36 + target_include_directories(wren 37 + PRIVATE 38 38 ${CMAKE_SOURCE_DIR}/include 39 39 ${CMAKE_SOURCE_DIR}/src 40 40 )
+30 -30
demos/benchmark.lua
··· 6 6 local runningTime = 0 7 7 local t = 0 8 8 local RUNNER = {} 9 - -- predictable random 9 + -- predictable random 10 10 -- give the same sequence every time 11 11 local random = {} 12 12 random.max = 8000 13 13 random.count = 0 14 - for x=0,random.max do 14 + for x=0,random.max do 15 15 random[x+1] = math.random(100)/100 16 16 end 17 17 function Random(v) 18 18 random.count = random.count+1 19 - return random[(random.count%random.max)+1] * v 19 + return random[(random.count%random.max)+1] * v 20 20 end 21 21 22 22 -- epilepsy warning ··· 57 57 cls(1) 58 58 print("Let the test run until the bar is full",0,0,15) 59 59 60 - -- print position 60 + -- print position 61 61 local yp = 68-((#UI.options*8)/2) 62 62 -- what is selected 63 63 local currentOption = 1+(UI.currentOption % (#UI.options)) 64 64 -- display options 65 - for o=1,#UI.options do 65 + for o=1,#UI.options do 66 66 color = 6 67 67 opt = UI.options[o] 68 - if o==currentOption then 68 + if o==currentOption then 69 69 color = 15 70 70 -- if highlighted and press Z 71 71 -- then start it ··· 74 74 RUNNER = opt[2] 75 75 -- if we have an INIT then run it 76 76 random.count = 0 77 - if RUNNER.init ~= nil then 77 + if RUNNER.init ~= nil then 78 78 RUNNER:init() 79 79 end 80 80 RUNNER.count = 0 ··· 102 102 function SQRT:run() 103 103 cls(0) 104 104 local wiggle= t/20 % 20 105 - for y=0,136 do 106 - for x=0,RUNNER.count do 105 + for y=0,136 do 106 + for x=0,RUNNER.count do 107 107 pix(x%240,y,16-(math.sqrt(wiggle+(x*x + y*y)/136)%16)) 108 108 end 109 109 end ··· 116 116 function SINCOS:run() 117 117 cls(0) 118 118 local wiggle= t/20 % 20 119 - for y=0,136 do 120 - for x=0,RUNNER.count do 119 + for y=0,136 do 120 + for x=0,RUNNER.count do 121 121 local v = 0 122 122 v = v + math.sin(wiggle+x) + math.cos(wiggle+y) 123 123 v = v + math.cos(wiggle-y) + math.sin(wiggle-x) ··· 134 134 end 135 135 function PIXELRW:run() 136 136 local wiggle= t/20 % 120 137 - for y=0,136 do 138 - for x=0,RUNNER.count do 137 + for y=0,136 do 138 + for x=0,RUNNER.count do 139 139 local a = pix(x+wiggle,y) 140 140 local b = Random(100) 141 141 if b<25 then ··· 152 152 function PIXELW:init() 153 153 end 154 154 function PIXELW:run() 155 - for y=0,136 do 156 - for x=0,RUNNER.count do 155 + for y=0,136 do 156 + for x=0,RUNNER.count do 157 157 pix(x&0xff,y,32+(x+(y*8))) 158 158 end 159 159 end ··· 163 163 local MATHRANDOM = { add = 1000 , callmult = 2} 164 164 function MATHRANDOM:run() 165 165 cls(0) 166 - for rc=0,RUNNER.count do 166 + for rc=0,RUNNER.count do 167 167 pix(math.random(240),math.random(136),math.random(15)) 168 168 end 169 169 end ··· 172 172 local SHAPES = { add = 25, callmult = 1} 173 173 function SHAPES:run() 174 174 cls(2) 175 - for x=0,RUNNER.count do 175 + for x=0,RUNNER.count do 176 176 circ(Random(240),Random(136),Random(16),x&1) 177 177 end 178 178 end 179 179 180 - -- map 180 + -- map 181 181 182 182 local MAP = { add = 1 , callmult = 1} 183 183 function MAP:run() 184 184 cls(10) 185 - for x=0,RUNNER.count do 185 + for x=0,RUNNER.count do 186 186 map(0,0,30,18,-x,0,10) 187 187 end 188 188 end ··· 193 193 function Sprites:run() 194 194 local a = t + 1/RUNNER.count 195 195 cls(0) 196 - for x=0,RUNNER.count do 196 + for x=0,RUNNER.count do 197 197 spr(1,120+math.sin(x+a)*120,68+math.cos(x-a)*68) 198 198 end 199 199 end ··· 209 209 table.sort(Particles, function(a,b) return a.y>b.y end) 210 210 211 211 if (t//40)&1==0 then 212 - if runningTime<16.2 then 212 + if runningTime<16.2 then 213 213 for x=1,100 do 214 214 table.insert(Particles.list,{x=Random(240),y=-Random(32),c=1+((x//10)%14),fs=0.5+Random(5)/10.0}) 215 215 end ··· 218 218 219 219 Particles.count = #Particles.list 220 220 221 - for x=1,#Particles.list do 221 + for x=1,#Particles.list do 222 222 p = Particles.list[x] 223 223 if p.y<100 then 224 - if (pix(p.x,(p.y+p.fs)//1)==0) then 224 + if (pix(p.x,(p.y+p.fs)//1)==0) then 225 225 p.y=p.y+p.fs 226 226 else 227 227 if Random(100)>80 then 228 - if (pix(p.x-1,p.y+1)==0) then 228 + if (pix(p.x-1,p.y+1)==0) then 229 229 p.x = p.x-1 230 - elseif (pix(p.x+1,p.y+1)==0) then 230 + elseif (pix(p.x+1,p.y+1)==0) then 231 231 p.x = p.x+1 232 232 end 233 233 end ··· 256 256 257 257 function MAINTIC() 258 258 local stime = time() 259 - if RUNNER~=nil then 259 + if RUNNER~=nil then 260 260 if RUNNER.count~=nil then 261 - if runningTime<16.6 then 261 + if runningTime<16.6 then 262 262 RUNNER.count=RUNNER.count + RUNNER.add 263 263 end 264 - if runningTime>18.0 then 264 + if runningTime>18.0 then 265 265 RUNNER.count=RUNNER.count - RUNNER.add 266 266 end 267 267 print(RUNNER.count,0,110,15) ··· 274 274 275 275 print(string.format("runTime %.2f",runningTime),1,127,0) 276 276 print(string.format("runTime %.2f",runningTime),0,126,15) 277 - if runningTime>16 then 277 + if runningTime>16 then 278 278 UI:bench() 279 279 end 280 280 end ··· 294 294 t=t+1 295 295 if (t>60*2) then 296 296 UI:bench() 297 - if btnp(4) then 297 + if btnp(4) then 298 298 TIC=MAINTIC 299 299 end 300 300 end
+2 -2
demos/bpp.lua
··· 1 1 -- title: Blit segment demo cart 2 2 -- author: ddelemeny 3 - -- desc: Variable BPP rendering 3 + -- desc: Variable BPP rendering 4 4 -- script: lua 5 5 6 6 W=16*4 ··· 84 84 -- font inverts BG and FG segments 85 85 -- blit segment = 8+4+page 86 86 rText(text, 100, 60, 8+4+sel//2,sel%2==1) 87 - end 87 + end 88 88 89 89 -- <TILES> 90 90 -- 032:0020505000205070002000500000007000200050000000000000000000000000
+1 -1
demos/bunny/jsmark.js
··· 1 1 // title: Bunnymark in JavaScript 2 2 // author: Rob Loach 3 3 // desc: Benchmarking tool to see how many bunnies can fly around the screen, using JavaScript. 4 - // license: MIT License 4 + // license: MIT License 5 5 // input: gamepad 6 6 // script: js 7 7 // version: 1.1.0
+1 -1
demos/bunny/moonmark.moon
··· 1 1 -- title: Bunnymark in MoonScript 2 2 -- author: Rob Loach 3 3 -- desc: Benchmarking tool to see how many bunnies can fly around the screen, using MoonScript. 4 - -- license: MIT License 4 + -- license: MIT License 5 5 -- input: gamepad 6 6 -- script: moon 7 7 -- version: 1.1.0
+1 -1
demos/bunny/pythonmark.py
··· 4 4 # input: gamepad 5 5 # script: python 6 6 # version: 0.0.0 7 - import random 7 + import random 8 8 9 9 screen_width = 240 10 10 screen_height = 136
+1 -1
demos/bunny/rubymark.rb
··· 1 1 # title: Bunnymark in Ruby 2 2 # author: Julia Nelz; based on the original work of Rob Loach 3 3 # desc: Benchmarking tool to see how many bunnies can fly around the screen, using Ruby. 4 - # license: MIT License 4 + # license: MIT License 5 5 # input: gamepad 6 6 # script: ruby 7 7 # version: 0.1.0
+2 -2
demos/bunny/schememark.scm
··· 1 1 ;; title: Bunnymark in Scheme 2 2 ;; author: David St-Hilaire, based on the original work of Rob Loach 3 3 ;; desc: Benchmarking tool to see how many bunnies can fly around the screen, using Scheme. 4 - ;; license: MIT License 4 + ;; license: MIT License 5 5 ;; input: gamepad 6 6 ;; script: scheme 7 7 ;; version: 1.1.0 ··· 13 13 14 14 (define (randomFloat lower greater) (+ (random (- greater lower) lower))) 15 15 16 - (defstruct bunny 16 + (defstruct bunny 17 17 (w 26) 18 18 (h 32) 19 19 (x (floor (random (- screenWidth 26))))
+1 -1
demos/bunny/squirrelmark.nut
··· 1 1 // title: Bunnymark in Squirrel 2 2 // author: Rob Loach 3 3 // desc: Benchmarking tool to see how many bunnies can fly around the screen, using Squirrel. 4 - // license: MIT License 4 + // license: MIT License 5 5 // input: gamepad 6 6 // script: squirrel 7 7 // version: 1.1.0
demos/bunny/wasmmark/wasmmark.wasm

This is a binary file and will not be displayed.

+2 -2
demos/bunny/wasmmark/wasmmark.wasmp
··· 8 8 9 9 """"""""""""""""""""""""""""""""""""""" 10 10 11 - This is a WASM binary project, you 11 + This is a WASM binary project, you 12 12 won't find the Zig source here. 13 13 14 - For source code see the TIC-80 14 + For source code see the TIC-80 15 15 repository folder: 16 16 17 17 /demos/bunny/wasmmark/
+1 -1
demos/bunny/wrenmark.wren
··· 1 1 // title: Bunnymark in Wren 2 2 // author: Rob Loach 3 3 // desc: Benchmarking tool to see how many bunnies can fly around the screen, using Wren. 4 - // license: MIT License 4 + // license: MIT License 5 5 // input: gamepad 6 6 // script: wren 7 7 // version: 1.1.0
+3 -3
demos/car.lua
··· 8 8 mesh={} -- Table that contains all the 3D points 9 9 polygon={} -- Table that contains all connections of 3D points to create triangle polygons, with their texture specified too 10 10 zorder={} -- Table used to know the rendering order of the triangles 11 - rspeed=.1 -- Rotation speed, you can change it 11 + rspeed=.1 -- Rotation speed, you can change it 12 12 tspeed=10 -- Translation speed, you can change it 13 13 14 14 function addMesh(mx,my,mz) ··· 183 183 p.u2,p.v2, 184 184 p.u3,p.v3, 185 185 0,{}, 186 - (m[p.p1].z+point.z), 187 - (m[p.p2].z+point.z), 186 + (m[p.p1].z+point.z), 187 + (m[p.p2].z+point.z), 188 188 (m[p.p3].z+point.z)) 189 189 end 190 190 end
+10 -10
demos/fire.lua
··· 21 21 table.insert(particle,p) 22 22 end 23 23 24 - function ticParticle() 24 + function ticParticle() 25 25 --print("#"..#particle) 26 26 local s=0 27 27 local s2=0 ··· 39 39 --remove old ones 40 40 if p.t > 300 then 41 41 table.remove(particle,k) 42 - end 43 - end 42 + end 43 + end 44 44 end 45 45 46 46 function TIC() ··· 48 48 if btn(0) then y=y-1 end 49 49 if btn(1) then y=y+1 end 50 50 if btn(2) then x=x-1 end 51 - if btn(3) then x=x+1 end 51 + if btn(3) then x=x+1 end 52 52 53 53 --warp space 54 54 x = x % 240 55 55 y = y % 136 56 56 57 57 --reset 58 - if btn(4) then 58 + if btn(4) then 59 59 x = 120 60 60 y = 120 61 61 end 62 62 63 - addParticle(x,y) 64 - addParticle(30,130) 65 - addParticle(210,130) 63 + addParticle(x,y) 64 + addParticle(30,130) 65 + addParticle(210,130) 66 66 67 67 cls(8) 68 68 69 - --Update & Draw particles 69 + --Update & Draw particles 70 70 ticParticle() 71 71 72 - --cursor 72 + --cursor 73 73 pix(x,y,7) 74 74 75 75 print("! FIRE !",94,64)
+10 -10
demos/p3d.lua
··· 47 47 p={x=x*r1, 48 48 y=y*r1, 49 49 z=(u/(l1+0.7)+v/5), 50 - c=pal[1+i%7]} 50 + c=pal[1+i%7]} 51 51 table.insert(points,p) 52 - end 52 + end 53 53 i=i+1 54 54 end 55 55 end ··· 80 80 b = p3d.y-center.y 81 81 c = p3d.z-center.z 82 82 83 - a1 = a*math.cos(az)-b*math.sin(az) 83 + a1 = a*math.cos(az)-b*math.sin(az) 84 84 b1 = a*math.sin(az)+b*math.cos(az) 85 85 c1 = c 86 86 87 - c2 = c1*math.cos(ay)-a1*math.sin(ay) 87 + c2 = c1*math.cos(ay)-a1*math.sin(ay) 88 88 a2 = c1*math.sin(ay)+a1*math.cos(ay) 89 89 b2 = b1 90 90 91 - b3 = b2*math.cos(ax)-c2*math.sin(ax) 91 + b3 = b2*math.cos(ax)-c2*math.sin(ax) 92 92 c3 = b2*math.sin(ax)+c2*math.cos(ax) 93 - a3 = a2 93 + a3 = a2 94 94 95 95 np3d.x=a3 96 96 np3d.y=b3 ··· 126 126 angle, 127 127 angle/2, 128 128 angle/4) 129 - points[k] = pr 130 - end 129 + points[k] = pr 130 + end 131 131 132 132 --Z Sort 133 133 table.sort(points,zsort) 134 134 135 135 --Draw points 136 136 for k,p in pairs(points)do 137 - i,j = p2d(p) 137 + i,j = p2d(p) 138 138 rect(i,j,6,6,p.c) 139 - end 139 + end 140 140 141 141 angle = angle + 0.05 142 142 t=t+1
+7 -7
demos/palette.lua
··· 38 38 local pal=PALETTES[index].data 39 39 for i=1,#pal,2 do 40 40 poke(ADDR+i//6*3+i//2%3,tonumber(pal:sub(i,i+1),16)) 41 - end 41 + end 42 42 end 43 43 44 44 updpal() ··· 46 46 function TIC() 47 47 48 48 -- handle input 49 - if btnp(0,20,5) and index>1 then 50 - index=index-1 49 + if btnp(0,20,5) and index>1 then 50 + index=index-1 51 51 updpal() 52 - end 53 - if btnp(1,20,5) and index<#PALETTES then 54 - index=index+1 52 + end 53 + if btnp(1,20,5) and index<#PALETTES then 54 + index=index+1 55 55 updpal() 56 56 end 57 57 ··· 64 64 print("SELECT PALETTE",6,6,0) 65 65 66 66 for i,v in pairs(PALETTES) do 67 - print(v.name,12,12+i*6,0) 67 + print(v.name,12,12+i*6,0) 68 68 end 69 69 70 70 print(">",6+(t//16%2),12+index*6,0)
+31 -31
demos/quest.lua
··· 82 82 elseif type(v)=="function" then 83 83 trace("["..i.."] ".."function") 84 84 end 85 - end 85 + end 86 86 trace("------------------") 87 87 end 88 88 ··· 96 96 local x=x+(CELL-w)/2 97 97 local y=y+(CELL-h)/2 98 98 99 - -- get the map ids in the edges 99 + -- get the map ids in the edges 100 100 local topLeft=mget(x/CELL,y/CELL) 101 101 local topRight=mget((x+w)/CELL,y/CELL) 102 102 local bottomLeft=mget(x/CELL,(y+h)/CELL) ··· 106 106 end 107 107 108 108 function Collision:CheckSolid(indx) 109 - return indx==tiles.WALL_1 or 109 + return indx==tiles.WALL_1 or 110 110 indx==tiles.WALL_2 or 111 111 indx==tiles.CLOSED_GRATE or 112 112 indx==tiles.MIMIC_HARM or ··· 116 116 indx==tiles.STATUE_2 or 117 117 indx==tiles.ALTAR or 118 118 indx==tiles.CRYSTAL_WHOLE or 119 - indx==tiles.CLOSED_DOOR or 120 - indx==tiles.CLOSED_COFFER or 119 + indx==tiles.CLOSED_DOOR or 120 + indx==tiles.CLOSED_COFFER or 121 121 indx==tiles.OPENED_COFFER 122 122 end 123 123 ··· 143 143 ended=false 144 144 } 145 145 146 - function s.Update(time) 146 + function s.Update(time) 147 147 if time>=s.tick and #s.frames>0 then 148 148 if s.loop then 149 149 s.indx=(s.indx+1)%#s.frames ··· 155 155 if s.indx==#s.frames then s.ended=true end 156 156 end 157 157 s.tick=time+s.span 158 - end 158 + end 159 159 end 160 160 161 161 function s.RandomIndx() ··· 245 245 visible=true 246 246 } 247 247 248 - function s.Move() 248 + function s.Move() 249 249 -- detect flip 250 250 if s.vx~=0 then s.flip=s.vx<0 and 1 or 0 end 251 251 ··· 271 271 if s.x<0 then s.x=0 end 272 272 if s.x>MAP_W-CELL then s.x=MAP_W-CELL end 273 273 if s.y<0 then s.y=0 end 274 - if s.y>MAP_H-CELL then s.y=MAP_H-CELL end 274 + if s.y>MAP_H-CELL then s.y=MAP_H-CELL end 275 275 end 276 276 277 277 function s.Collide() ··· 310 310 -- if the range is exceeded, ends the life of the bullet 311 311 local dx=s.x-s.xStart 312 312 local dy=s.y-s.yStart 313 - if math.sqrt(dx^2+dy^2)>s.range then s.Collide() end 313 + if math.sqrt(dx^2+dy^2)>s.range then s.Collide() end 314 314 end 315 315 316 316 function s.Display(time) ··· 322 322 if s.visible then 323 323 spr(s.curAnim.frame,x,y,s.alpha,1,s.flip) 324 324 -- rectb(x,y,CELL,CELL,14) 325 - end 325 + end 326 326 end 327 327 328 328 return s ··· 340 340 health=3, 341 341 power=1, 342 342 fov=6*CELL, 343 - proximity=CELL-2, 343 + proximity=CELL-2, 344 344 died=false, 345 345 dx=0, 346 346 dy=0, ··· 485 485 if s.visible then 486 486 spr(s.curAnim.frame,x,y,s.alpha,1,s.flip) 487 487 -- rectb(x,y,CELL,CELL,14) 488 - end 488 + end 489 489 end 490 490 491 491 return s ··· 534 534 535 535 s.anims={ 536 536 idle=Anim(25,{128,129,130,131}), 537 - walk=Anim(15,{128,129,130,131}), 537 + walk=Anim(15,{128,129,130,131}), 538 538 attack=Anim(15,{132,133,128},false), 539 539 die=Anim(5,{132,137,138,139,140,141},false), 540 540 damaged=Anim(20,{142,128},false) ··· 613 613 if s.visible then 614 614 spr(s.curAnim.frame,x,y,s.alpha,1,s.flip) 615 615 spr(s.curAnim.frame-16,x,y-CELL,s.alpha,1,s.flip) 616 - end 616 + end 617 617 end 618 618 619 619 return s ··· 632 632 633 633 s.anims={ 634 634 idle=Anim(60,{16,17}), 635 - walk=Anim(15,{18,19}), 635 + walk=Anim(15,{18,19}), 636 636 attack=Anim(15,{20,17},false), 637 637 die=Anim(5,{21,22,23,24,25},false), 638 638 damaged=Anim(20,{26,17},false) ··· 654 654 CheckKeys(dx,dy) 655 655 end 656 656 657 - function s.Update(time) 657 + function s.Update(time) 658 658 s.dx=0 659 659 s.dy=0 660 660 ··· 667 667 end 668 668 669 669 -- prevent update in these particular states 670 - if s.died or s.attack then return end 670 + if s.died or s.attack then return end 671 671 672 672 -- default: idle 673 673 if not s.damaged then s.curAnim=s.anims.idle end ··· 741 741 742 742 if tl==tiles.CLOSED_COFFER then 743 743 mset((s.x+dx)/CELL,(s.y+dy)/CELL,tiles.OPENED_COFFER) 744 - if math.random(100)<probability then s.potions=s.potions+1 end 744 + if math.random(100)<probability then s.potions=s.potions+1 end 745 745 elseif tr==tiles.CLOSED_COFFER then 746 746 mset((s.x+dx+CELL-1)/CELL,(s.y+dy)/CELL,tiles.OPENED_COFFER) 747 - if math.random(100)<probability then s.potions=s.potions+1 end 747 + if math.random(100)<probability then s.potions=s.potions+1 end 748 748 elseif bl==tiles.CLOSED_COFFER then 749 749 mset((s.x+dx)/CELL,(s.y+dy+CELL-1)/CELL,tiles.OPENED_COFFER) 750 750 if math.random(100)<probability then s.potions=s.potions+1 end ··· 761 761 tl,tr,bl,br=Collision:GetEdges(s.x+dx,s.y+dy) 762 762 if tl==tiles.KEY_FLOOR then 763 763 s.keys=s.keys+1 764 - mset((s.x+dx)/CELL,(s.y+dy)/CELL,tiles.KEY_FLOOR_PICKED_UP) 764 + mset((s.x+dx)/CELL,(s.y+dy)/CELL,tiles.KEY_FLOOR_PICKED_UP) 765 765 elseif tr==tiles.KEY_FLOOR then 766 766 s.keys=s.keys+1 767 767 mset((s.x+dx+CELL-1)/CELL,(s.y+dy)/CELL,tiles.KEY_FLOOR_PICKED_UP) ··· 819 819 m.tag="blob" 820 820 m.anims={ 821 821 idle=Anim(20,{32,33,34}), 822 - walk=Anim(8,{34,35,36,37,38}), 822 + walk=Anim(8,{34,35,36,37,38}), 823 823 attack=Anim(5,{39,40,41,32},false), 824 824 die=Anim(5,{42,43,44},false), 825 825 damaged=Anim(20,{45,32},false), ··· 836 836 m.score=2 837 837 m.anims={ 838 838 idle=Anim(60,{48,49}), 839 - walk=Anim(15,{50,51}), 839 + walk=Anim(15,{50,51}), 840 840 attack=Anim(15,{52,49},false), 841 841 die=Anim(5,{53,54,55,56},false), 842 842 damaged=Anim(20,{57,49},false), ··· 849 849 m.tag="wraith" 850 850 m.anims={ 851 851 idle=Anim(25,{80,81,82,81}), 852 - walk=Anim(15,{80,81,82,81}), 852 + walk=Anim(15,{80,81,82,81}), 853 853 attack=Anim(20,{83,80},false), 854 854 die=Anim(5,{90,91,92,93},false), 855 855 damaged=Anim(20,{94,95,80},false) ··· 867 867 move=Anim(5,{84,85,86}), 868 868 collided=Anim(15,{87,88,89},false) 869 869 } 870 - return b 870 + return b 871 871 end 872 872 873 873 return m ··· 882 882 m.fov=4*CELL 883 883 m.anims={ 884 884 idle=Anim(60,{64,65}), 885 - walk=Anim(15,{66,67}), 885 + walk=Anim(15,{66,67}), 886 886 attack=Anim(15,{68,69,70,64},false), 887 887 die=Anim(20,{71,72,73,74},false), 888 888 damaged=Anim(20,{75,64},false), ··· 899 899 m.fov=7*CELL 900 900 m.anims={ 901 901 idle=Anim(50,{96,97}), 902 - walk=Anim(15,{98,99}), 902 + walk=Anim(15,{98,99}), 903 903 attack=Anim(15,{100,97},false), 904 904 die=Anim(5,{101,102,103,104,105},false), 905 905 damaged=Anim(20,{106,97},false) ··· 996 996 997 997 -- just for curiosity 998 998 local maxScore=0 999 - for i,mob in pairs(mobs) do 999 + for i,mob in pairs(mobs) do 1000 1000 maxScore=maxScore+mob.score 1001 1001 end 1002 1002 -- trace("maxScore:"..maxScore) 1003 1003 1004 1004 -- cycle the map and manage the special elements 1005 1005 for y=0,MAP_W/CELL do 1006 - for x=0,MAP_H/CELL do 1006 + for x=0,MAP_H/CELL do 1007 1007 -- animated tiles 1008 1008 if mget(x,y)==tiles.LAVA_1 or mget(x,y)==tiles.LAVA_2 or mget(x,y)==tiles.LAVA_3 then 1009 1009 local tile=AnimTile(x,y,Anim(30,{tiles.LAVA_1,tiles.LAVA_2,tiles.LAVA_3})) ··· 1070 1070 end 1071 1071 end 1072 1072 1073 - ------------------------------------------ 1073 + ------------------------------------------ 1074 1074 -- main 1075 1075 function TIC() 1076 1076 -- runs only the first time or to reset the game ··· 1102 1102 1103 1103 ------------- DISPLAY ------------- 1104 1104 -- animated tiles 1105 - for i,tile in pairs(animTiles) do tile.Display(t) end 1105 + for i,tile in pairs(animTiles) do tile.Display(t) end 1106 1106 -- mobs 1107 1107 for i,mob in pairs(mobs) do mob.Display(t) end 1108 1108 -- player
+38 -38
demos/tetris.lua
··· 148 148 local function remove(oldSprId) 149 149 local process=true 150 150 while process do 151 - process=false 151 + process=false 152 152 for y=1,s.height do 153 153 if s.grid[y][1] == oldSprId then 154 154 removeLine(y) 155 155 process=true 156 156 break 157 - end 157 + end 158 158 end 159 159 end 160 160 end ··· 166 166 s.animTime=now 167 167 remove(DIE2_CELL_SPR) 168 168 s.isAnim = replace(DIE1_CELL_SPR, DIE2_CELL_SPR) 169 - end 169 + end 170 170 end 171 171 172 172 return s ··· 196 196 for x=1,s.width do 197 197 if sh~=nil and sh[y][x]>0 then 198 198 local posX=x+pos.x 199 - local posY=y+pos.y 199 + local posY=y+pos.y 200 200 201 201 if posX<=0 or posX>grid.width then 202 - return true 202 + return true 203 203 elseif posY>grid.height then 204 - return true 204 + return true 205 205 elseif not (grid.grid[posY][posX]==EMPTY_CELL_SPR) then 206 - return true 206 + return true 207 207 end 208 208 end 209 209 end ··· 220 220 for x=1,s.width do 221 221 if shape~=nil and shape[y][x]>0 then 222 222 local posX=cx+x-1+s.pos.x 223 - local posY=cy+y-1+s.pos.y 223 + local posY=cy+y-1+s.pos.y 224 224 DrawToCell(s.sprId,posX,posY) 225 225 end 226 226 end ··· 236 236 237 237 function s.GoDown(grid) 238 238 local p={x=s.pos.x,y=s.pos.y} 239 - p.y=p.y+1 239 + p.y=p.y+1 240 240 241 241 if not isCollision(grid,s.shape,p) then 242 242 s.pos=p ··· 247 247 248 248 function s.GoLeft(grid) 249 249 local p={x=s.pos.x,y=s.pos.y} 250 - p.x=p.x-1 250 + p.x=p.x-1 251 251 252 252 if not isCollision(grid,s.shape,p) then 253 253 s.pos=p ··· 281 281 s.pos = pLeft 282 282 s.shape = shape 283 283 return 284 - end 285 - end 284 + end 285 + end 286 286 287 287 end 288 288 ··· 358 358 {0,1,0}, 359 359 {1,1,0}, 360 360 {1,0,0} 361 - } 361 + } 362 362 end 363 363 364 364 return s ··· 371 371 s.width=3 372 372 s.height=3 373 373 s.shape=1 374 - s.wallkickGap=1 374 + s.wallkickGap=1 375 375 s.shapes[1]={ 376 376 {0,1,1}, 377 377 {1,1,0}, ··· 394 394 {1,0,0}, 395 395 {1,1,0}, 396 396 {0,1,0} 397 - } 397 + } 398 398 end 399 399 400 400 return s ··· 407 407 s.width=3 408 408 s.height=3 409 409 s.shape=1 410 - s.wallkickGap=1 410 + s.wallkickGap=1 411 411 s.shapes[1]={ 412 412 {0,0,1}, 413 413 {1,1,1}, ··· 430 430 {1,1,0}, 431 431 {0,1,0}, 432 432 {0,1,0} 433 - } 433 + } 434 434 end 435 435 436 436 return s ··· 443 443 s.width=3 444 444 s.height=3 445 445 s.shape=1 446 - s.wallkickGap=1 446 + s.wallkickGap=1 447 447 s.shapes[1]={ 448 448 {1,0,0}, 449 449 {1,1,1}, ··· 466 466 {0,1,0}, 467 467 {0,1,0}, 468 468 {1,1,0} 469 - } 469 + } 470 470 end 471 471 472 472 return s ··· 479 479 s.width=3 480 480 s.height=3 481 481 s.shape=1 482 - s.wallkickGap=1 482 + s.wallkickGap=1 483 483 s.shapes[1]={ 484 484 {0,1,0}, 485 485 {1,1,1}, ··· 502 502 {0,1,0}, 503 503 {1,1,0}, 504 504 {0,1,0} 505 - } 505 + } 506 506 end 507 507 508 508 return s ··· 515 515 s.width=4 516 516 s.height=4 517 517 s.shape=1 518 - s.wallkickGap=2 518 + s.wallkickGap=2 519 519 s.shapes[1]={ 520 520 {0,0,0,0}, 521 521 {1,1,1,1}, ··· 542 542 {0,1,0,0}, 543 543 {0,1,0,0}, 544 544 {0,1,0,0} 545 - } 545 + } 546 546 end 547 547 548 548 return s ··· 555 555 s.width=4 556 556 s.height=3 557 557 s.shape=1 558 - s.wallkickGap=0 558 + s.wallkickGap=0 559 559 s.shapes[1]={ 560 560 {0,1,1,0}, 561 561 {0,1,1,0}, ··· 578 578 {0,1,1,0}, 579 579 {0,1,1,0}, 580 580 {0,0,0,0} 581 - } 581 + } 582 582 end 583 583 584 584 return s ··· 732 732 function s.GoTo(name) 733 733 for i,screen in pairs(s.items) do 734 734 if screen.name == name then 735 - leave() 735 + leave() 736 736 s.current = screen 737 - enter() 737 + enter() 738 738 end 739 739 end 740 740 end ··· 770 770 771 771 local function onNewGame() 772 772 gameScreen.Reset() 773 - screenMng.GoTo(GAME_SCR) 773 + screenMng.GoTo(GAME_SCR) 774 774 end 775 775 776 776 local function onSoundChanged(itemMenu) ··· 804 804 s.menu = Menu(2) 805 805 806 806 local function onContinue() 807 - screenMng.GoTo(GAME_SCR) 807 + screenMng.GoTo(GAME_SCR) 808 808 end 809 809 810 810 local function onMenu() ··· 846 846 s.isGameOver=false 847 847 848 848 local function onPause() 849 - screenMng.GoTo(PAUSE_SCR) 849 + screenMng.GoTo(PAUSE_SCR) 850 850 s.pauseTime=time() 851 851 end 852 852 ··· 861 861 s.current.Move(3,0) 862 862 s.fallTime=time() 863 863 864 - s.next = s.spawner.Spawn() 864 + s.next = s.spawner.Spawn() 865 865 s.next.Create() 866 866 end 867 867 end ··· 910 910 if score==0 then 911 911 soundMng.PlaySfx(FELL_SFX) 912 912 else 913 - soundMng.PlaySfx(LINE_SFX) 913 + soundMng.PlaySfx(LINE_SFX) 914 914 end 915 915 916 916 score=score+4*s.level ··· 993 993 PrintToCell("Best: ",1,4,6) 994 994 PrintToCell(best,1,5,15) 995 995 996 - --Level 996 + --Level 997 997 local level = string.format("%02d", s.level) 998 998 PrintToCell("Level: ",1,13,6) 999 - PrintToCell(level,2,14,15) 999 + PrintToCell(level,2,14,15) 1000 1000 1001 1001 s.grid.Draw(9,0) 1002 - s.next.Draw(23,2) 1002 + s.next.Draw(23,2) 1003 1003 if s.current~=nil then 1004 1004 s.current.Draw(9,0) 1005 1005 end ··· 1025 1025 1026 1026 function s.OnLeave() 1027 1027 soundMng.BreakSfx(GAME_OVER_SFX) 1028 - end 1028 + end 1029 1029 1030 1030 function s.Update() 1031 1031 local now=time() 1032 1032 local isTime=(now>start+delay) 1033 1033 local isBtn=btnp(4) or btnp(5) 1034 - if isTime or isBtn then 1034 + if isTime or isBtn then 1035 1035 onMenu() 1036 1036 end 1037 1037 end ··· 1258 1258 soundMng.LoadSettings() 1259 1259 soundMng.Add(FellSfx()) 1260 1260 soundMng.Add(LineSfx()) 1261 - soundMng.Add(GameOverSfx()) 1261 + soundMng.Add(GameOverSfx()) 1262 1262 soundMng.Add(MenuSfx()) 1263 1263 soundMng.Add(SelMenuSfx()) 1264 1264
+5 -5
demos/wasm/src/main.zig
··· 19 19 20 20 if (tic.btn(0)) { 21 21 mascot.y -= 1; 22 - } 22 + } 23 23 if (tic.btn(1)) { 24 24 mascot.y +=1; 25 - } 25 + } 26 26 if (tic.btn(2)) { 27 27 mascot.x -= 1; 28 - } 28 + } 29 29 if (tic.btn(3)) { 30 30 mascot.x += 1; 31 - } 31 + } 32 32 33 33 tic.cls(13); 34 - tic.spr(@as(i32, 1+t%60/30*2),mascot.x,mascot.y,.{ 34 + tic.spr(@as(i32, 1+t%60/30*2),mascot.x,mascot.y,.{ 35 35 .transparent = &.{14}, 36 36 .scale = 3, 37 37 .w = 2,
+5 -5
demos/wasm/wasmdemo.wasmp
··· 2 2 -- script: wasm 3 3 4 4 """"""""""""""""""""""""""""""""""""""" 5 - WASM is a binary format. The demo 6 - binary code is embedded in this 5 + WASM is a binary format. The demo 6 + binary code is embedded in this 7 7 cartridge, the source code is not. 8 8 Run the cart to see the demo. 9 9 ··· 11 11 you can't (yet) develop WASM projects 12 12 using the built-in editor. 13 13 14 - The code used to build this project 14 + The code used to build this project 15 15 can be found in the TIC-80 repo: 16 16 17 17 https://github.com/nesbox/TIC-80 18 18 /demos/wasm/ 19 19 20 - This demo was built with Zig, but many 21 - languages are supported. You simply 20 + This demo was built with Zig, but many 21 + languages are supported. You simply 22 22 build your project with your external 23 23 compiler, then import the final WASM 24 24 binary into your cartridge:
+1 -1
include/tic80.h
··· 55 55 TIC80_PIXEL_COLOR_BGRA8888 = (4 << 8) | 32 56 56 } tic80_pixel_color_format; 57 57 58 - typedef struct 58 + typedef struct 59 59 { 60 60 struct 61 61 {
+2 -2
include/tic80_config.h
··· 23 23 #pragma once 24 24 25 25 #if defined(__APPLE__) 26 - // TODO: this disables macos config 26 + // TODO: this disables macos config 27 27 # include "AvailabilityMacros.h" 28 28 # include "TargetConditionals.h" 29 29 // # ifndef TARGET_OS_IPHONE ··· 41 41 # if defined(_MSC_VER) && defined(_USING_V110_SDK71_) 42 42 # define __TIC_WIN7__ 1 43 43 # endif 44 - # endif 44 + # endif 45 45 # if defined(ANDROID) || defined(__ANDROID__) 46 46 # undef __TIC_ANDROID__ 47 47 # define __TIC_ANDROID__ 1
+3 -3
src/api.h
··· 40 40 TraceOutput trace; 41 41 ErrorOutput error; 42 42 ExitCallback exit; 43 - 43 + 44 44 CounterCallback counter; 45 45 FreqCallback freq; 46 46 u64 start; ··· 88 88 } tic_rect; 89 89 90 90 // SYNC DEFINITION TABLE 91 - // .--------------------------------- - - - 91 + // .--------------------------------- - - - 92 92 // | CART | RAM | INDEX 93 - // |---------+---------------+------- - - - 93 + // |---------+---------------+------- - - - 94 94 // | | | 95 95 #define TIC_SYNC_LIST(macro) \ 96 96 macro(tiles, tiles, 0) \
+22 -22
src/api/js.c
··· 70 70 const char *str; 71 71 72 72 tic_core* core = getCore(ctx); 73 - 73 + 74 74 str = JS_ToCString(ctx, val); 75 - if (str) 75 + if (str) 76 76 { 77 77 core->data->error(core->data->data, str); 78 78 JS_FreeCString(ctx, str); 79 79 } 80 - else 80 + else 81 81 { 82 82 core->data->error(core->data->data, "[exception]\n"); 83 83 } ··· 87 87 { 88 88 JSValue val; 89 89 bool is_error; 90 - 90 + 91 91 is_error = JS_IsError(ctx, exception_val); 92 92 js_dump_obj(ctx, stdout, exception_val); 93 - if (is_error) 93 + if (is_error) 94 94 { 95 95 val = JS_GetPropertyStr(ctx, exception_val, "stack"); 96 - if (!JS_IsUndefined(val)) 96 + if (!JS_IsUndefined(val)) 97 97 { 98 98 js_dump_obj(ctx, stdout, val); 99 99 } ··· 104 104 static void js_std_dump_error(JSContext *ctx) 105 105 { 106 106 JSValue exception_val; 107 - 107 + 108 108 exception_val = JS_GetException(ctx); 109 109 js_std_dump_error1(ctx, exception_val); 110 110 JS_FreeValue(ctx, exception_val); ··· 243 243 244 244 s32 scale = getInteger2(ctx, argv[4], 1); 245 245 246 - tic_flip flip = JS_IsBool(argv[5]) 246 + tic_flip flip = JS_IsBool(argv[5]) 247 247 ? JS_ToBool(ctx, argv[5]) ? tic_horz_flip : tic_no_flip 248 248 : getInteger2(ctx, argv[5], tic_no_flip); 249 249 ··· 294 294 295 295 if(key < tic_keys_count) 296 296 return JS_NewBool(ctx, core->api.key(tic, key)); 297 - else 297 + else 298 298 { 299 299 JSValue err = JS_NewError(ctx); 300 300 JS_SetPropertyStr(ctx, err, "message", JS_NewString(ctx, "unknown keyboard code")); ··· 328 328 329 329 return JS_NewBool(ctx, core->api.keyp(tic, key, hold, period)); 330 330 } 331 - else 331 + else 332 332 { 333 333 throwError(ctx, "unknown keyboard code"); 334 334 } ··· 419 419 RemapData* remap = (RemapData*)data; 420 420 JSContext* ctx = remap->ctx; 421 421 422 - JSValue res = JS_Call(ctx, remap->func, JS_UNDEFINED, 3, 422 + JSValue res = JS_Call(ctx, remap->func, JS_UNDEFINED, 3, 423 423 (JSValueConst[]) 424 424 { 425 - JS_NewInt32(ctx, result->index), 426 - JS_NewInt32(ctx, x), 427 - JS_NewInt32(ctx, y), 425 + JS_NewInt32(ctx, result->index), 426 + JS_NewInt32(ctx, x), 427 + JS_NewInt32(ctx, y), 428 428 }); 429 429 430 430 if(JS_IsArray(ctx, res)) ··· 830 830 count = 1; 831 831 } 832 832 833 - core->api.textri(tic, 833 + core->api.textri(tic, 834 834 pt[0], pt[1], // xy 1 835 835 pt[2], pt[3], // xy 2 836 836 pt[4], pt[5], // xy 3 ··· 889 889 pt[10], pt[11], // uv 3 890 890 src, // texture source 891 891 colors, count, // chroma 892 - z[0], z[1], z[2], depth); // depth 892 + z[0], z[1], z[2], depth); // depth 893 893 894 894 return JS_UNDEFINED; 895 895 } ··· 1196 1196 1197 1197 static const char* const JsKeywords [] = 1198 1198 { 1199 - "await", "break", "case", "catch", "class", "const", "continue", "debugger", 1200 - "default", "delete", "do", "else", "enum", "export", "extends", "false", 1201 - "finally", "for", "function", "if", "implements", "import", "in", "instanceof", 1202 - "interface", "let", "new", "null", "package", "private", "protected", 1203 - "public", "return", "super", "switch", "static", "this", "throw", "try", 1199 + "await", "break", "case", "catch", "class", "const", "continue", "debugger", 1200 + "default", "delete", "do", "else", "enum", "export", "extends", "false", 1201 + "finally", "for", "function", "if", "implements", "import", "in", "instanceof", 1202 + "interface", "let", "new", "null", "package", "private", "protected", 1203 + "public", "return", "super", "switch", "static", "this", "throw", "try", 1204 1204 "true", "typeof", "var", "void", "while", "with", "yield", "of" 1205 1205 }; 1206 1206 ··· 1266 1266 return items; 1267 1267 } 1268 1268 1269 - static void evalJs(tic_mem* tic, const char* code) 1269 + static void evalJs(tic_mem* tic, const char* code) 1270 1270 { 1271 1271 tic_core* core = (tic_core*)tic; 1272 1272 core->data->error(core->data->data, "TODO: JS eval not yet implemented\n.");
+3 -3
src/api/lua.c
··· 60 60 "and", "break", "do", "else", "elseif", 61 61 "end", "false", "for", "function", "goto", "if", 62 62 "in", "local", "nil", "not", "or", "repeat", 63 - "return", "then", "true", "until", "while", 63 + "return", "then", "true", "until", "while", 64 64 "self" 65 65 }; 66 66 ··· 126 126 return items; 127 127 } 128 128 129 - static void evalLua(tic_mem* tic, const char* code) 129 + static void evalLua(tic_mem* tic, const char* code) 130 130 { 131 131 tic_core* core = (tic_core*)tic; 132 132 lua_State* lua = core->currentVM; ··· 206 206 #include "../build/assets/car.tic.dat" 207 207 }; 208 208 209 - TIC_EXPORT const tic_script EXPORT_SCRIPT(Lua) = 209 + TIC_EXPORT const tic_script EXPORT_SCRIPT(Lua) = 210 210 { 211 211 .id = 10, 212 212 .name = "lua",
+35 -35
src/api/luaapi.c
··· 217 217 { 218 218 s32 x = getLuaNumber(lua, 1); 219 219 s32 y = getLuaNumber(lua, 2); 220 - 220 + 221 221 tic_core* core = getLuaCore(lua); 222 222 tic_mem* tic = (tic_mem*)core; 223 223 ··· 309 309 s32 top = lua_gettop(lua); 310 310 311 311 if(top == 4) 312 - { 312 + { 313 313 tic_core* core = getLuaCore(lua); 314 314 tic_mem* tic = (tic_mem*)core; 315 315 ··· 351 351 s32 top = lua_gettop(lua); 352 352 353 353 if(top == 5) 354 - { 354 + { 355 355 tic_core* core = getLuaCore(lua); 356 356 tic_mem* tic = (tic_mem*)core; 357 357 ··· 376 376 { 377 377 tic_core* core = getLuaCore(lua); 378 378 tic_mem* tic = (tic_mem*)core; 379 - 379 + 380 380 s32 x = getLuaNumber(lua, 1); 381 381 s32 y = getLuaNumber(lua, 2); 382 382 s32 a = getLuaNumber(lua, 3); ··· 400 400 401 401 for(s32 i = 0; i < COUNT_OF(pt); i++) 402 402 pt[i] = lua_tonumber(lua, i+1); 403 - 403 + 404 404 s32 color = getLuaNumber(lua, 7); 405 405 406 406 tic_core* core = getLuaCore(lua); ··· 423 423 424 424 for(s32 i = 0; i < COUNT_OF(pt); i++) 425 425 pt[i] = lua_tonumber(lua, i+1); 426 - 426 + 427 427 s32 color = getLuaNumber(lua, 7); 428 428 429 429 tic_core* core = getLuaCore(lua); ··· 455 455 s32 count = 0; 456 456 bool use_map = false; 457 457 458 - // check for use map 458 + // check for use map 459 459 if (top >= 13) 460 460 use_map = lua_toboolean(lua, 13); 461 461 462 - // check for chroma 462 + // check for chroma 463 463 if(top >= 14) 464 464 { 465 465 if(lua_istable(lua, 14)) ··· 480 480 } 481 481 } 482 482 } 483 - else 483 + else 484 484 { 485 485 colors[0] = getLuaNumber(lua, 14); 486 486 count = 1; 487 487 } 488 488 } 489 489 490 - core->api.textri(tic, 490 + core->api.textri(tic, 491 491 pt[0], pt[1], // xy 1 492 492 pt[2], pt[3], // xy 2 493 493 pt[4], pt[5], // xy 3 ··· 523 523 // check for texture src 524 524 if (top >= 13) 525 525 { 526 - src = lua_isboolean(lua, 13) 527 - ? (lua_toboolean(lua, 13) ? tic_map_texture : tic_tiles_texture) 526 + src = lua_isboolean(lua, 13) 527 + ? (lua_toboolean(lua, 13) ? tic_map_texture : tic_tiles_texture) 528 528 : lua_tointeger(lua, 13); 529 529 } 530 - // check for chroma 530 + // check for chroma 531 531 if(top >= 14) 532 532 { 533 533 if(lua_istable(lua, 14)) ··· 548 548 } 549 549 } 550 550 } 551 - else 551 + else 552 552 { 553 553 colors[0] = getLuaNumber(lua, 14); 554 554 count = 1; ··· 663 663 { 664 664 luaL_error(lua, "invalid params, btn [ id ]\n"); 665 665 return 0; 666 - } 666 + } 667 667 668 668 return 1; 669 669 } ··· 683 683 static u8 colors[TIC_PALETTE_SIZE]; 684 684 s32 count = 0; 685 685 686 - if(top >= 1) 686 + if(top >= 1) 687 687 { 688 688 index = getLuaNumber(lua, 1); 689 689 ··· 712 712 } 713 713 } 714 714 } 715 - else 715 + else 716 716 { 717 717 colors[0] = getLuaNumber(lua, 4); 718 718 count = 1; ··· 827 827 828 828 s32 top = lua_gettop(lua); 829 829 830 - if(top >= 2) 830 + if(top >= 2) 831 831 { 832 832 x = getLuaNumber(lua, 1); 833 833 y = getLuaNumber(lua, 2); ··· 862 862 } 863 863 } 864 864 } 865 - else 865 + else 866 866 { 867 867 colors[0] = getLuaNumber(lua, 7); 868 868 count = 1; ··· 888 888 luaL_unref(lua, LUA_REGISTRYINDEX, data.reg); 889 889 890 890 return 0; 891 - } 891 + } 892 892 } 893 893 } 894 894 } ··· 1041 1041 speed = getLuaNumber(lua, 6); 1042 1042 } 1043 1043 } 1044 - } 1044 + } 1045 1045 } 1046 1046 } 1047 1047 ··· 1140 1140 { 1141 1141 luaL_error(lua, "invalid params, key [code]\n"); 1142 1142 return 0; 1143 - } 1143 + } 1144 1144 1145 1145 return 1; 1146 1146 } ··· 1311 1311 { 1312 1312 s32 top = lua_gettop(lua); 1313 1313 1314 - if(top >= 1) 1314 + if(top >= 1) 1315 1315 { 1316 1316 tic_core* core = getLuaCore(lua); 1317 1317 tic_mem* tic = (tic_mem*)core; ··· 1411 1411 1412 1412 lua_pushinteger(lua, val); 1413 1413 1414 - return 1; 1414 + return 1; 1415 1415 } 1416 1416 1417 1417 luaL_error(lua, "invalid persistent tic index\n"); ··· 1425 1425 { 1426 1426 tic_core* core = getLuaCore(lua); 1427 1427 tic_mem* tic = (tic_mem*)core; 1428 - 1428 + 1429 1429 lua_pushnumber(lua, core->api.time(tic)); 1430 1430 1431 1431 return 1; ··· 1447 1447 tic_mem* tic = (tic_mem*)core; 1448 1448 1449 1449 core->api.exit(tic); 1450 - 1450 + 1451 1451 return 0; 1452 1452 } 1453 1453 ··· 1611 1611 1612 1612 void luaapi_init(tic_core* core) 1613 1613 { 1614 - static const struct{lua_CFunction func; const char* name;} ApiItems[] = 1614 + static const struct{lua_CFunction func; const char* name;} ApiItems[] = 1615 1615 { 1616 1616 #define API_FUNC_DEF(name, ...) {lua_ ## name, #name}, 1617 1617 TIC_API_LIST(API_FUNC_DEF) 1618 1618 #undef API_FUNC_DEF 1619 1619 1620 - #if defined(BUILD_DEPRECATED) 1620 + #if defined(BUILD_DEPRECATED) 1621 1621 {lua_textri, "textri"}, 1622 1622 #endif 1623 1623 }; ··· 1644 1644 ** Message handler which appends stract trace to exceptions. 1645 1645 ** This function was extractred from lua.c. 1646 1646 */ 1647 - static s32 msghandler (lua_State *lua) 1647 + static s32 msghandler (lua_State *lua) 1648 1648 { 1649 1649 const char *msg = lua_tostring(lua, 1); 1650 1650 if (msg == NULL) /* is error object not a string? */ ··· 1664 1664 ** Please use this function for all top level lua functions. 1665 1665 ** This function was extractred from lua.c (and stripped of signal handling) 1666 1666 */ 1667 - static s32 docall (lua_State *lua, s32 narg, s32 nres) 1667 + static s32 docall (lua_State *lua, s32 narg, s32 nres) 1668 1668 { 1669 1669 s32 status = 0; 1670 1670 s32 base = lua_gettop(lua) - narg; /* function index */ ··· 1684 1684 if(lua) 1685 1685 { 1686 1686 lua_getglobal(lua, TIC_FN); 1687 - if(lua_isfunction(lua, -1)) 1687 + if(lua_isfunction(lua, -1)) 1688 1688 { 1689 - if(docall(lua, 0, 0) != LUA_OK) 1690 - { 1689 + if(docall(lua, 0, 0) != LUA_OK) 1690 + { 1691 1691 core->data->error(core->data->data, lua_tostring(lua, -1)); 1692 1692 return; 1693 1693 } ··· 1708 1708 } 1709 1709 #endif 1710 1710 } 1711 - else 1712 - { 1711 + else 1712 + { 1713 1713 lua_pop(lua, 1); 1714 1714 core->data->error(core->data->data, "'function TIC()...' isn't found :("); 1715 1715 }
+1 -1
src/api/moonscript.c
··· 196 196 #include "../build/assets/moonmark.tic.dat" 197 197 }; 198 198 199 - TIC_EXPORT const tic_script EXPORT_SCRIPT(Moon) = 199 + TIC_EXPORT const tic_script EXPORT_SCRIPT(Moon) = 200 200 { 201 201 .id = 13, 202 202 .name = "moon",
+10 -10
src/api/mruby.c
··· 64 64 static mrb_value mrb_poke(mrb_state* mrb, mrb_value self) 65 65 { 66 66 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 67 - 67 + 68 68 69 69 mrb_int address, value; 70 70 mrb_int bits = BITS_IN_BYTE; ··· 78 78 static mrb_value mrb_peek1(mrb_state* mrb, mrb_value self) 79 79 { 80 80 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 81 - 81 + 82 82 83 83 mrb_int address; 84 84 mrb_get_args(mrb, "i", &address); ··· 89 89 static mrb_value mrb_poke1(mrb_state* mrb, mrb_value self) 90 90 { 91 91 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 92 - 92 + 93 93 94 94 mrb_int address, value; 95 95 mrb_get_args(mrb, "ii", &address, &value); ··· 102 102 static mrb_value mrb_peek2(mrb_state* mrb, mrb_value self) 103 103 { 104 104 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 105 - 105 + 106 106 107 107 mrb_int address; 108 108 mrb_get_args(mrb, "i", &address); ··· 113 113 static mrb_value mrb_poke2(mrb_state* mrb, mrb_value self) 114 114 { 115 115 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 116 - 116 + 117 117 118 118 mrb_int address, value; 119 119 mrb_get_args(mrb, "ii", &address, &value); ··· 126 126 static mrb_value mrb_peek4(mrb_state* mrb, mrb_value self) 127 127 { 128 128 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 129 - 129 + 130 130 131 131 mrb_int address; 132 132 mrb_get_args(mrb, "i", &address); ··· 137 137 static mrb_value mrb_poke4(mrb_state* mrb, mrb_value self) 138 138 { 139 139 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 140 - 140 + 141 141 142 142 mrb_int address, value; 143 143 mrb_get_args(mrb, "ii", &address, &value); ··· 364 364 static mrb_value mrb_btnp(mrb_state* mrb, mrb_value self) 365 365 { 366 366 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 367 - 367 + 368 368 369 369 mrb_int index, hold, period; 370 370 mrb_int argc = mrb_get_args(mrb, "|iii", &index, &hold, &period); ··· 391 391 static mrb_value mrb_btn(mrb_state* mrb, mrb_value self) 392 392 { 393 393 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 394 - 394 + 395 395 396 396 mrb_int index, hold, period; 397 397 mrb_int argc = mrb_get_args(mrb, "|i", &index, &hold, &period); ··· 808 808 static mrb_value mrb_keyp(mrb_state* mrb, mrb_value self) 809 809 { 810 810 tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; 811 - 811 + 812 812 813 813 mrb_int key, hold, period; 814 814 mrb_int argc = mrb_get_args(mrb, "|iii", &key, &hold, &period);
+146 -146
src/api/python.c
··· 21 21 pkpy_setglobal(vm, pkpy_name(name)); 22 22 } 23 23 24 - static bool get_core(pkpy_vm* vm, tic_core** core) 24 + static bool get_core(pkpy_vm* vm, tic_core** core) 25 25 { 26 26 bool ok = pkpy_getglobal(vm, N._tic_core); 27 27 if(!ok) return false; ··· 30 30 return ok; 31 31 } 32 32 33 - static bool setup_core(pkpy_vm* vm, tic_core* core) 33 + static bool setup_core(pkpy_vm* vm, tic_core* core) 34 34 { 35 35 if (!pkpy_push_voidp(vm, core)) return false; 36 36 return pkpy_setglobal(vm, N._tic_core); 37 37 } 38 38 39 39 //index should be a positive index 40 - static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) 40 + static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) 41 41 { 42 - if (pkpy_is_int(vm, index)) 42 + if (pkpy_is_int(vm, index)) 43 43 { 44 44 int value; 45 45 pkpy_to_int(vm, index, &value); ··· 51 51 buffer[0] = value; 52 52 return 1; 53 53 } 54 - } 55 - else 54 + } 55 + else 56 56 { //should be a list then 57 57 pkpy_getglobal(vm, N.len); 58 58 pkpy_push_null(vm); ··· 65 65 66 66 list_len = (list_len < TIC_PALETTE_SIZE)?(list_len):(TIC_PALETTE_SIZE); 67 67 68 - for(int i = 0; i < list_len; i++) 68 + for(int i = 0; i < list_len; i++) 69 69 { 70 70 int list_val; 71 71 pkpy_dup(vm, index); //get the list ··· 81 81 } 82 82 } 83 83 84 - static int py_trace(pkpy_vm* vm) 84 + static int py_trace(pkpy_vm* vm) 85 85 { 86 86 pkpy_CString message; 87 87 int color; ··· 94 94 pkpy_to_int(vm, 1, &color); 95 95 96 96 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 97 - if (pkpy_check_error(vm)) 97 + if (pkpy_check_error(vm)) 98 98 { 99 99 return 0; 100 100 } ··· 103 103 return 0; 104 104 } 105 105 106 - static int py_cls(pkpy_vm* vm) 106 + static int py_cls(pkpy_vm* vm) 107 107 { 108 - 108 + 109 109 int color; 110 110 111 111 pkpy_to_int(vm, 0, &color); 112 112 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 113 - if (pkpy_check_error(vm)) 113 + if (pkpy_check_error(vm)) 114 114 return 0; 115 115 116 116 core->api.cls(tic, (u8) color); 117 117 return 0; 118 118 } 119 119 120 - static int py_btn(pkpy_vm* vm) 120 + static int py_btn(pkpy_vm* vm) 121 121 { 122 - 122 + 123 123 int button_id; 124 124 125 125 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; ··· 132 132 return 1; 133 133 } 134 134 135 - static int py_btnp(pkpy_vm* vm) 135 + static int py_btnp(pkpy_vm* vm) 136 136 { 137 - 137 + 138 138 int button_id; 139 139 int hold; 140 140 int period; ··· 151 151 return 1; 152 152 } 153 153 154 - static int py_circ(pkpy_vm* vm) 154 + static int py_circ(pkpy_vm* vm) 155 155 { 156 - 156 + 157 157 int x; 158 158 int y; 159 159 int radius; ··· 171 171 return 0; 172 172 } 173 173 174 - static int py_circb(pkpy_vm* vm) 174 + static int py_circb(pkpy_vm* vm) 175 175 { 176 - 176 + 177 177 int x; 178 178 int y; 179 179 int radius; ··· 191 191 return 0; 192 192 } 193 193 194 - static int py_elli(pkpy_vm* vm) 194 + static int py_elli(pkpy_vm* vm) 195 195 { 196 - 196 + 197 197 int x; 198 198 int y; 199 199 int a; ··· 213 213 return 0; 214 214 } 215 215 216 - static int py_ellib(pkpy_vm* vm) 216 + static int py_ellib(pkpy_vm* vm) 217 217 { 218 - 218 + 219 219 int x; 220 220 int y; 221 221 int a; ··· 235 235 return 0; 236 236 } 237 237 238 - static int py_clip(pkpy_vm* vm) 238 + static int py_clip(pkpy_vm* vm) 239 239 { 240 - 240 + 241 241 int x; 242 242 int y; 243 243 int w; ··· 255 255 return 0; 256 256 } 257 257 258 - static int py_exit(pkpy_vm* vm) 258 + static int py_exit(pkpy_vm* vm) 259 259 { 260 - 260 + 261 261 262 262 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 263 263 if(pkpy_check_error(vm)) ··· 267 267 return 0; 268 268 } 269 269 270 - static int py_fget(pkpy_vm* vm) 270 + static int py_fget(pkpy_vm* vm) 271 271 { 272 - 272 + 273 273 int sprite_id; 274 274 int flag; 275 275 ··· 284 284 return 1; 285 285 } 286 286 287 - static int py_fset(pkpy_vm* vm) 287 + static int py_fset(pkpy_vm* vm) 288 288 { 289 - 289 + 290 290 int sprite_id; 291 291 int flag; 292 292 bool set_to; ··· 302 302 return 0; 303 303 } 304 304 305 - static int py_font(pkpy_vm* vm) 305 + static int py_font(pkpy_vm* vm) 306 306 { 307 - 307 + 308 308 pkpy_CString text; 309 309 int x; 310 310 int y; ··· 329 329 return 0; 330 330 } 331 331 332 - if (scale == 0) 332 + if (scale == 0) 333 333 { 334 334 pkpy_push_int(vm, 0); 335 335 return 1; 336 - } 337 - 336 + } 337 + 338 338 u8 chromakey = (u8) chromakey_raw; 339 339 340 340 s32 size = core->api.font(tic, text, x, y, &chromakey, 1, width, height, fixed, scale, alt); ··· 343 343 return 1; 344 344 } 345 345 346 - static int py_key(pkpy_vm* vm) 346 + static int py_key(pkpy_vm* vm) 347 347 { 348 - 348 + 349 349 int key_id; 350 350 351 351 pkpy_to_int(vm, 0, &key_id); ··· 363 363 return 1; 364 364 } 365 365 366 - static int py_keyp(pkpy_vm* vm) 366 + static int py_keyp(pkpy_vm* vm) 367 367 { 368 - 368 + 369 369 int key_id; 370 370 int hold; 371 371 int period; ··· 387 387 return 1; 388 388 } 389 389 390 - static int py_line(pkpy_vm* vm) 390 + static int py_line(pkpy_vm* vm) 391 391 { 392 - 392 + 393 393 double x0; 394 394 double y0; 395 395 double x1; ··· 430 430 result->rotate = rotate; 431 431 } 432 432 433 - static int py_map(pkpy_vm* vm) 433 + static int py_map(pkpy_vm* vm) 434 434 { 435 - 435 + 436 436 int x; 437 437 int y; 438 438 int w; ··· 455 455 pkpy_to_int(vm, 7, &scale); 456 456 used_remap = !pkpy_is_none(vm, 8); 457 457 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 458 - if(pkpy_check_error(vm)) 458 + if(pkpy_check_error(vm)) 459 459 return 0; 460 460 461 461 //last element on the stack should be the function, so no need to adjust anything 462 - if (used_remap) 462 + if (used_remap) 463 463 core->api.map(tic, x, y, w, h, sx, sy, colors, color_count, scale, remap_callback, vm); 464 - else 464 + else 465 465 core->api.map(tic, x, y, w, h, sx, sy, colors, color_count, scale, NULL, NULL); 466 466 467 467 return 0; 468 468 } 469 469 470 470 static int py_memcpy(pkpy_vm* vm) { 471 - 472 - 471 + 472 + 473 473 int dest; 474 474 int src; 475 475 int size; ··· 478 478 pkpy_to_int(vm, 1, &src); 479 479 pkpy_to_int(vm, 2, &size); 480 480 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 481 - if(pkpy_check_error(vm)) 481 + if(pkpy_check_error(vm)) 482 482 return 0; 483 483 484 484 core->api.memcpy(tic, dest, src, size); ··· 487 487 } 488 488 489 489 static int py_memset(pkpy_vm* vm) { 490 - 491 - 490 + 491 + 492 492 int dest; 493 493 int value; 494 494 int size; ··· 497 497 pkpy_to_int(vm, 1, &value); 498 498 pkpy_to_int(vm, 2, &size); 499 499 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 500 - if(pkpy_check_error(vm)) 500 + if(pkpy_check_error(vm)) 501 501 return 0; 502 502 503 503 core->api.memset(tic, dest, value, size); ··· 506 506 } 507 507 508 508 static int py_mget(pkpy_vm* vm) { 509 - 510 - 509 + 510 + 511 511 int x; 512 512 int y; 513 513 514 514 pkpy_to_int(vm, 0, &x); 515 515 pkpy_to_int(vm, 1, &y); 516 516 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 517 - if(pkpy_check_error(vm)) 517 + if(pkpy_check_error(vm)) 518 518 return 0; 519 519 520 520 int value = core->api.mget(tic, x, y); ··· 524 524 } 525 525 526 526 static int py_mset(pkpy_vm* vm) { 527 - 528 - 527 + 528 + 529 529 int x; 530 530 int y; 531 531 int tile_id; ··· 534 534 pkpy_to_int(vm, 1, &y); 535 535 pkpy_to_int(vm, 2, &tile_id); 536 536 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 537 - if(pkpy_check_error(vm)) 537 + if(pkpy_check_error(vm)) 538 538 return 0; 539 539 540 540 core->api.mset(tic, x, y, tile_id); ··· 544 544 545 545 546 546 static int py_mouse(pkpy_vm* vm) { 547 - 547 + 548 548 tic_core* core; 549 549 get_core(vm, &core); 550 - if(pkpy_check_error(vm)) 550 + if(pkpy_check_error(vm)) 551 551 return 0; 552 552 553 553 tic_point pos = core->api.mouse((tic_mem*)core); ··· 566 566 } 567 567 568 568 static int py_music(pkpy_vm* vm) { 569 - 570 - 569 + 570 + 571 571 int track; 572 572 int frame; 573 573 int row; ··· 584 584 pkpy_to_int(vm, 5, &tempo); 585 585 pkpy_to_int(vm, 6, &speed); 586 586 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 587 - if(pkpy_check_error(vm)) 587 + if(pkpy_check_error(vm)) 588 588 return 0; 589 589 590 590 if (track > MUSIC_TRACKS - 1 ) ··· 599 599 } 600 600 601 601 static int py_peek(pkpy_vm* vm) { 602 - 603 - 602 + 603 + 604 604 int address; 605 605 int bits; 606 606 607 607 pkpy_to_int(vm, 0, &address); 608 608 pkpy_to_int(vm, 1, &bits); 609 609 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 610 - if(pkpy_check_error(vm)) 610 + if(pkpy_check_error(vm)) 611 611 return 0; 612 612 613 613 int value = core->api.peek(tic, address, bits); ··· 617 617 } 618 618 619 619 static int py_peek1(pkpy_vm* vm) { 620 - 621 - 620 + 621 + 622 622 int address; 623 623 624 624 pkpy_to_int(vm, 0, &address); 625 625 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 626 - if(pkpy_check_error(vm)) 626 + if(pkpy_check_error(vm)) 627 627 return 0; 628 628 629 629 int value = core->api.peek1(tic, address); ··· 633 633 } 634 634 635 635 static int py_peek2(pkpy_vm* vm) { 636 - 637 - 636 + 637 + 638 638 int address; 639 639 640 640 pkpy_to_int(vm, 0, &address); 641 641 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 642 - if(pkpy_check_error(vm)) 642 + if(pkpy_check_error(vm)) 643 643 return 0; 644 644 645 645 int value = core->api.peek2(tic, address); ··· 649 649 } 650 650 651 651 static int py_peek4(pkpy_vm* vm) { 652 - 653 - 652 + 653 + 654 654 int address; 655 655 656 656 pkpy_to_int(vm, 0, &address); 657 657 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 658 - if(pkpy_check_error(vm)) 658 + if(pkpy_check_error(vm)) 659 659 return 0; 660 660 661 661 int value = core->api.peek4(tic, address); ··· 665 665 } 666 666 667 667 static int py_pix(pkpy_vm* vm) { 668 - 668 + 669 669 int x; 670 670 int y; 671 671 int color = -1; ··· 676 676 677 677 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 678 678 679 - if(pkpy_check_error(vm)) 679 + if(pkpy_check_error(vm)) 680 680 return 0; 681 681 682 682 if(color >= 0) { //set the pixel ··· 690 690 } 691 691 692 692 static int py_pmem(pkpy_vm* vm) { 693 - 693 + 694 694 int index; 695 695 bool provided_value = false; 696 696 int value; ··· 701 701 pkpy_to_int(vm, 1, &value); 702 702 } 703 703 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 704 - if(pkpy_check_error(vm)) 704 + if(pkpy_check_error(vm)) 705 705 return 0; 706 706 707 707 if (index >= TIC_PERSISTENT_SIZE) { ··· 719 719 } 720 720 721 721 static int py_poke(pkpy_vm* vm) { 722 - 723 - 722 + 723 + 724 724 int address; 725 725 int value; 726 726 int bits; ··· 729 729 pkpy_to_int(vm, 1, &value); 730 730 pkpy_to_int(vm, 2, &bits); 731 731 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 732 - if(pkpy_check_error(vm)) 732 + if(pkpy_check_error(vm)) 733 733 return 0; 734 734 735 735 core->api.poke(tic, address, value, bits); ··· 738 738 } 739 739 740 740 static int py_poke1(pkpy_vm* vm) { 741 - 742 - 741 + 742 + 743 743 int address; 744 744 int value; 745 745 746 746 pkpy_to_int(vm, 0, &address); 747 747 pkpy_to_int(vm, 1, &value); 748 748 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 749 - if(pkpy_check_error(vm)) 749 + if(pkpy_check_error(vm)) 750 750 return 0; 751 751 752 752 core->api.poke1(tic, address, value); ··· 755 755 } 756 756 757 757 static int py_poke2(pkpy_vm* vm) { 758 - 759 - 758 + 759 + 760 760 int address; 761 761 int value; 762 762 763 763 pkpy_to_int(vm, 0, &address); 764 764 pkpy_to_int(vm, 1, &value); 765 765 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 766 - if(pkpy_check_error(vm)) 766 + if(pkpy_check_error(vm)) 767 767 return 0; 768 768 769 769 core->api.poke2(tic, address, value); ··· 772 772 } 773 773 774 774 static int py_poke4(pkpy_vm* vm) { 775 - 776 - 775 + 776 + 777 777 int address; 778 778 int value; 779 779 780 780 pkpy_to_int(vm, 0, &address); 781 781 pkpy_to_int(vm, 1, &value); 782 782 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 783 - if(pkpy_check_error(vm)) 783 + if(pkpy_check_error(vm)) 784 784 return 0; 785 785 786 786 core->api.poke4(tic, address, value); ··· 789 789 } 790 790 791 791 static int py_print(pkpy_vm* vm) { 792 - 793 - 792 + 793 + 794 794 pkpy_CString text; 795 795 int x; 796 796 int y; ··· 820 820 return 1; 821 821 } 822 822 823 - static int py_rect(pkpy_vm* vm) 823 + static int py_rect(pkpy_vm* vm) 824 824 { 825 - 825 + 826 826 int x; 827 827 int y; 828 828 int w; ··· 842 842 return 0; 843 843 } 844 844 845 - static int py_rectb(pkpy_vm* vm) 845 + static int py_rectb(pkpy_vm* vm) 846 846 { 847 - 847 + 848 848 int x; 849 849 int y; 850 850 int w; ··· 864 864 return 0; 865 865 } 866 866 867 - static int py_sfx(pkpy_vm* vm) 867 + static int py_sfx(pkpy_vm* vm) 868 868 { 869 - 869 + 870 870 int sfx_id; 871 871 872 872 bool parse_note_flag = false; ··· 892 892 pkpy_to_int(vm, 4, &volume); 893 893 pkpy_to_int(vm, 5, &speed); 894 894 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 895 - if(pkpy_check_error(vm)) 895 + if(pkpy_check_error(vm)) 896 896 goto cleanup; 897 897 s32 note, octave; 898 898 ··· 901 901 pkpy_error(vm, "RuntimeError", pkpy_string("invalid note, should like C#4\n")); 902 902 goto cleanup; //error in future; 903 903 } 904 - 904 + 905 905 } else { 906 906 note = int_note % NOTES; 907 907 octave = int_note/ NOTES; ··· 925 925 return 0; 926 926 } 927 927 928 - static int py_spr(pkpy_vm* vm) 928 + static int py_spr(pkpy_vm* vm) 929 929 { 930 - 930 + 931 931 int spr_id; 932 932 int x; 933 933 int y; ··· 950 950 pkpy_to_int(vm, 7, &w); 951 951 pkpy_to_int(vm, 8, &h); 952 952 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 953 - if(pkpy_check_error(vm)) 953 + if(pkpy_check_error(vm)) 954 954 return 0; 955 955 956 956 core->api.spr(tic, spr_id, x, y, w, h, colors, color_count, scale, flip, rotate); ··· 961 961 static int py_reset(pkpy_vm* vm) { 962 962 tic_core* core; 963 963 get_core(vm, &core); 964 - if(pkpy_check_error(vm)) 964 + if(pkpy_check_error(vm)) 965 965 return 0; 966 966 967 967 core->state.initialized = false; ··· 969 969 return 0; 970 970 } 971 971 972 - static int py_sync(pkpy_vm* vm) 972 + static int py_sync(pkpy_vm* vm) 973 973 { 974 - 974 + 975 975 int mask; 976 976 int bank; 977 977 bool tocart; ··· 993 993 return 0; 994 994 } 995 995 996 - static int py_time(pkpy_vm* vm) 996 + static int py_time(pkpy_vm* vm) 997 997 { 998 - 998 + 999 999 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 1000 1000 if(pkpy_check_error(vm)) 1001 1001 return 0; ··· 1005 1005 return 1; 1006 1006 } 1007 1007 1008 - static int py_tstamp(pkpy_vm* vm) 1008 + static int py_tstamp(pkpy_vm* vm) 1009 1009 { 1010 - 1010 + 1011 1011 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 1012 1012 if(pkpy_check_error(vm)) 1013 1013 return 0; ··· 1017 1017 return 1; 1018 1018 } 1019 1019 1020 - static int py_tri(pkpy_vm* vm) 1020 + static int py_tri(pkpy_vm* vm) 1021 1021 { 1022 - 1022 + 1023 1023 double x1; 1024 1024 double y1; 1025 1025 double x2; ··· 1043 1043 return 0; 1044 1044 } 1045 1045 1046 - static int py_trib(pkpy_vm* vm) 1046 + static int py_trib(pkpy_vm* vm) 1047 1047 { 1048 - 1048 + 1049 1049 double x1; 1050 1050 double y1; 1051 1051 double x2; ··· 1069 1069 return 0; 1070 1070 } 1071 1071 1072 - static int py_ttri(pkpy_vm* vm) 1072 + static int py_ttri(pkpy_vm* vm) 1073 1073 { 1074 - 1074 + 1075 1075 double x1; 1076 1076 double y1; 1077 1077 double x2; ··· 1114 1114 pkpy_to_float(vm, 16, &z3); 1115 1115 1116 1116 tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; 1117 - if(pkpy_check_error(vm)) 1117 + if(pkpy_check_error(vm)) 1118 1118 return 0; 1119 1119 1120 1120 core->api.ttri( 1121 - tic, 1122 - x1,y1,x2,y2,x3,y3, 1123 - u1,v1,u2,v2,u3,v3, 1124 - texsrc, 1125 - colors,color_count, 1121 + tic, 1122 + x1,y1,x2,y2,x3,y3, 1123 + u1,v1,u2,v2,u3,v3, 1124 + texsrc, 1125 + colors,color_count, 1126 1126 z1,z2,z3, 1127 1127 z1 != 0 || z2 != 0 || z3 != 0 1128 1128 ); ··· 1138 1138 if (!pkpy_is_none(vm, 0)) 1139 1139 pkpy_to_int(vm, 0, &bank_id); 1140 1140 get_core(vm, &core); 1141 - if(pkpy_check_error(vm)) 1141 + if(pkpy_check_error(vm)) 1142 1142 return 0; 1143 1143 1144 1144 tic_mem* tic = (tic_mem*) core; ··· 1326 1326 return true; 1327 1327 } 1328 1328 1329 - void closePython(tic_mem* tic) 1329 + void closePython(tic_mem* tic) 1330 1330 { 1331 1331 tic_core* core = (tic_core*)tic; 1332 1332 ··· 1341 1341 pkpy_vm* vm = core->currentVM; 1342 1342 core->data->error(core->data->data, prefix); 1343 1343 char* message; 1344 - if (!pkpy_clear_error(vm, &message)) 1344 + if (!pkpy_clear_error(vm, &message)) 1345 1345 core->data->error(core->data->data, "error was thrown but not register (pocketpy c binding bug)"); 1346 1346 else 1347 1347 core->data->error(core->data->data, message); 1348 1348 } 1349 1349 1350 - static bool initPython(tic_mem* tic, const char* code) 1350 + static bool initPython(tic_mem* tic, const char* code) 1351 1351 { 1352 1352 N._tic_core = pkpy_name("_tic_core"); 1353 1353 N.len = pkpy_name("len"); ··· 1375 1375 return false; 1376 1376 } 1377 1377 1378 - if(!pkpy_exec(vm, code)) 1378 + if(!pkpy_exec(vm, code)) 1379 1379 { 1380 1380 report_error(core, "error while processing the main code\n"); 1381 1381 ··· 1385 1385 return true; 1386 1386 } 1387 1387 1388 - void callPythonTick(tic_mem* tic) 1388 + void callPythonTick(tic_mem* tic) 1389 1389 { 1390 1390 tic_core* core = (tic_core*)tic; 1391 - if (!core->currentVM) 1391 + if (!core->currentVM) 1392 1392 return; 1393 1393 1394 1394 if(!pkpy_getglobal(core->currentVM, N.TIC)) return; ··· 1402 1402 } 1403 1403 void callPythonBoot(tic_mem* tic) { 1404 1404 tic_core* core = (tic_core*)tic; 1405 - if (!core->currentVM) 1405 + if (!core->currentVM) 1406 1406 return; 1407 1407 1408 1408 if(!pkpy_getglobal(core->currentVM, N.BOOT)) return; 1409 - 1409 + 1410 1410 pkpy_push_null(core->currentVM); 1411 1411 if(!pkpy_vectorcall(core->currentVM, 0)){ 1412 1412 report_error(core, "error while running BOOT\n"); ··· 1417 1417 1418 1418 void callPythonScanline(tic_mem* tic, s32 row, void* data) { 1419 1419 tic_core* core = (tic_core*)tic; 1420 - if (!core->currentVM) 1420 + if (!core->currentVM) 1421 1421 return; 1422 1422 1423 1423 if(!pkpy_getglobal(core->currentVM, N.SCN)) return; ··· 1433 1433 1434 1434 void callPythonBorder(tic_mem* tic, s32 row, void* data) { 1435 1435 tic_core* core = (tic_core*)tic; 1436 - if (!core->currentVM) 1436 + if (!core->currentVM) 1437 1437 return; 1438 1438 1439 1439 if(!pkpy_getglobal(core->currentVM, N.BDR)) return; ··· 1449 1449 1450 1450 void callPythonMenu(tic_mem* tic, s32 index, void* data) { 1451 1451 tic_core* core = (tic_core*)tic; 1452 - if (!core->currentVM) 1452 + if (!core->currentVM) 1453 1453 return; 1454 1454 1455 1455 if(pkpy_getglobal(core->currentVM, N.MENU)) return; ··· 1465 1465 1466 1466 static bool is_alnum_(char c) { 1467 1467 return ( 1468 - (c >= 'a' && c <= 'z') 1469 - || (c >= 'A' && c <= 'Z') 1470 - || (c >= '0' && c <= '9') 1468 + (c >= 'a' && c <= 'z') 1469 + || (c >= 'A' && c <= 'Z') 1470 + || (c >= '0' && c <= '9') 1471 1471 || (c == '_') 1472 1472 ); 1473 1473 } 1474 1474 1475 - static const tic_outline_item* getPythonOutline(const char* code, s32* size) 1475 + static const tic_outline_item* getPythonOutline(const char* code, s32* size) 1476 1476 { 1477 1477 1478 1478 *size = 0; 1479 1479 static tic_outline_item* items = NULL; 1480 - if (items) 1480 + if (items) 1481 1481 { 1482 1482 free(items); 1483 1483 items = NULL; ··· 1487 1487 1488 1488 start: 1489 1489 if (*code == 0) goto end; 1490 - else if (strncmp(code, "def", 3) == 0) { code += 3; goto next_word_ws; } 1490 + else if (strncmp(code, "def", 3) == 0) { code += 3; goto next_word_ws; } 1491 1491 else if (*code == '#') { code++; goto comment; } 1492 1492 else if (strncmp(code, "\"\"\"", 3) == 0) { code += 3; goto multiline_string; } 1493 1493 else if (*code == '"') { code++; goto string; } ··· 1502 1502 next_word : 1503 1503 if (is_alnum_(*code)) { code++; goto next_word; } 1504 1504 else //store item 1505 - { 1505 + { 1506 1506 items = realloc(items, (*size + 1) * sizeof(tic_outline_item)); 1507 1507 items[*size].pos = name_start; 1508 1508 items[*size].size = (s32)(code - name_start); ··· 1540 1540 1541 1541 } 1542 1542 1543 - void evalPython(tic_mem* tic, const char* code) 1543 + void evalPython(tic_mem* tic, const char* code) 1544 1544 { 1545 1545 tic_core* core = (tic_core*)tic; 1546 1546 pkpy_vm* vm = core->currentVM; 1547 1547 if (!vm) return; 1548 1548 1549 - if(!pkpy_exec(vm, code)) 1549 + if(!pkpy_exec(vm, code)) 1550 1550 { 1551 1551 report_error(core, "error while evaluating the code\n"); 1552 1552 }
+12 -12
src/api/scheme.c
··· 76 76 else{ 77 77 return s7_make_integer(sc, core->api.pix(tic, x, y, 0, true)); 78 78 } 79 - 79 + 80 80 } 81 81 s7_pointer scheme_line(s7_scheme* sc, s7_pointer args) 82 82 { ··· 166 166 // btn(id) -> pressed 167 167 tic_core* core = getSchemeCore(sc); tic_mem* tic = (tic_mem*)core; 168 168 const s32 id = s7_integer(s7_car(args)); 169 - 169 + 170 170 return s7_make_boolean(sc, core->api.btn(tic, id)); 171 171 } 172 172 s7_pointer scheme_btnp(s7_scheme* sc, s7_pointer args) ··· 178 178 const int argn = s7_list_length(sc, args); 179 179 const s32 hold = argn > 1 ? s7_integer(s7_cadr(args)) : -1; 180 180 const s32 period = argn > 2 ? s7_integer(s7_caddr(args)) : -1; 181 - 181 + 182 182 return s7_make_boolean(sc, core->api.btnp(tic, id, hold, period)); 183 183 } 184 184 ··· 215 215 // sfx(id note=-1 duration=-1 channel=0 volume=15 speed=0) 216 216 tic_core* core = getSchemeCore(sc); tic_mem* tic = (tic_mem*)core; 217 217 const s32 id = s7_integer(s7_car(args)); 218 - 218 + 219 219 const int argn = s7_list_length(sc, args); 220 220 int note = -1; 221 221 int octave = -1; ··· 252 252 /* } */ 253 253 } 254 254 } 255 - 255 + 256 256 const s32 duration = argn > 2 ? s7_integer(s7_caddr(args)) : -1; 257 257 const s32 channel = argn > 3 ? s7_integer(s7_cadddr(args)) : 0; 258 258 ··· 512 512 tic_core* core = getSchemeCore(sc); tic_mem* tic = (tic_mem*)core; 513 513 const tic_point point = core->api.mouse(tic); 514 514 const tic80_mouse* mouse = &((tic_core*)tic)->memory.ram->input.mouse; 515 - 515 + 516 516 return 517 517 s7_cons(sc, s7_make_integer(sc, point.x), 518 518 s7_cons(sc, s7_make_integer(sc, point.y), ··· 616 616 617 617 const int argn = s7_list_length(sc, args); 618 618 const tic_texture_src texsrc = (tic_texture_src)(argn > 12 ? s7_integer(s7_list_ref(sc, args, 12)) : 0); 619 - 619 + 620 620 static u8 trans_colors[TIC_PALETTE_SIZE]; 621 621 u8 trans_count = 0; 622 622 ··· 732 732 const u8 flag = s7_integer(s7_cadr(args)); 733 733 const bool val = s7_boolean(sc, s7_caddr(args)); 734 734 core->api.fset(tic, sprite_id, flag, val); 735 - return s7_nil(sc); 735 + return s7_nil(sc); 736 736 } 737 737 738 738 s7_pointer scheme_fft(s7_scheme* sc, s7_pointer args) ··· 766 766 767 767 #define API_FUNC_DEF(name, desc, helpstr, count, reqcount, ...) \ 768 768 {scheme_ ## name, desc "\n" helpstr, count, reqcount, "t80::" #name}, 769 - 769 + 770 770 static const struct{s7_function func; const char* helpstr; int count; int reqcount; const char* name;} ApiItems[] = 771 771 {TIC_API_LIST(API_FUNC_DEF)}; 772 - 772 + 773 773 #undef API_FUNC_DEF 774 774 775 775 for (s32 i = 0; i < COUNT_OF(ApiItems); i++) { ··· 847 847 848 848 s7_define_variable(sc, TicCore, s7_make_c_pointer(sc, core)); 849 849 s7_load_c_string(sc, code, strlen(code)); 850 - 850 + 851 851 852 852 const bool isTicDefined = s7_is_defined(sc, ticFnName); 853 853 if (!isTicDefined) { ··· 1029 1029 return; 1030 1030 sc = core->currentVM; 1031 1031 } 1032 - 1032 + 1033 1033 s7_eval_c_string(sc, code); 1034 1034 } 1035 1035
+44 -44
src/api/squirrel.c
··· 48 48 SQInteger i; 49 49 if (SQ_SUCCEEDED(sq_getinteger(vm, index, &i))) 50 50 return (s32)i; 51 - 51 + 52 52 return (s32)getSquirrelFloat(vm, index); 53 53 } 54 54 ··· 85 85 #endif 86 86 } 87 87 88 - void squirrel_compilerError(HSQUIRRELVM vm, const SQChar* desc, const SQChar* source, 88 + void squirrel_compilerError(HSQUIRRELVM vm, const SQChar* desc, const SQChar* source, 89 89 SQInteger line, SQInteger column) 90 90 { 91 91 tic_core* core = getSquirrelCore(vm); 92 92 char buffer[1024]; 93 93 snprintf(buffer, 1023, "%.40s line %.6d column %.6d: %s\n", source, (int)line, (int)column, desc); 94 - 94 + 95 95 if (core->data) 96 96 core->data->error(core->data->data, buffer); 97 97 } ··· 106 106 { 107 107 char buffer[100]; 108 108 snprintf(buffer, 99, "%.40s %.40s %.6d\n", si.funcname, si.source, (int)si.line); 109 - 109 + 110 110 if (core->data) 111 111 core->data->error(core->data->data, buffer); 112 112 ++level; ··· 118 118 119 119 static SQInteger squirrel_peek(HSQUIRRELVM vm) 120 120 { 121 - tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; 121 + tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; 122 122 SQInteger top = sq_gettop(vm); 123 123 124 124 // check number of args ··· 258 258 { 259 259 s32 x = getSquirrelNumber(vm, 2); 260 260 s32 y = getSquirrelNumber(vm, 3); 261 - 261 + 262 262 tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; 263 263 264 264 if(top >= 4) ··· 346 346 SQInteger top = sq_gettop(vm); 347 347 348 348 if(top == 5) 349 - { 349 + { 350 350 s32 x = getSquirrelNumber(vm, 2); 351 351 s32 y = getSquirrelNumber(vm, 3); 352 352 s32 radius = getSquirrelNumber(vm, 4); ··· 433 433 434 434 for(s32 i = 0; i < COUNT_OF(pt); i++) 435 435 pt[i] = getSquirrelFloat(vm, i + 2); 436 - 436 + 437 437 s32 color = getSquirrelNumber(vm, 8); 438 438 439 439 tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; ··· 455 455 456 456 for(s32 i = 0; i < COUNT_OF(pt); i++) 457 457 pt[i] = getSquirrelFloat(vm, i + 2); 458 - 458 + 459 459 s32 color = getSquirrelNumber(vm, 8); 460 460 461 461 tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; ··· 488 488 { 489 489 src = getSquirrelNumber(vm, 14); 490 490 } 491 - // check for chroma 491 + // check for chroma 492 492 if(OT_ARRAY == sq_gettype(vm, 15)) 493 493 { 494 494 for(s32 i = 0; i < TIC_PALETTE_SIZE; i++) ··· 508 508 } 509 509 } 510 510 } 511 - else 511 + else 512 512 { 513 513 colors[0] = getSquirrelNumber(vm, 15); 514 514 count = 1; ··· 618 618 else 619 619 { 620 620 return sq_throwerror(vm, "invalid params, btn [ id ]\n"); 621 - } 621 + } 622 622 623 623 return 1; 624 624 } ··· 638 638 static u8 colors[TIC_PALETTE_SIZE]; 639 639 s32 count = 0; 640 640 641 - if(top >= 2) 641 + if(top >= 2) 642 642 { 643 643 index = getSquirrelNumber(vm, 2); 644 644 ··· 668 668 } 669 669 } 670 670 } 671 - else 671 + else 672 672 { 673 673 colors[0] = getSquirrelNumber(vm, 5); 674 674 count = 1; ··· 756 756 HSQUIRRELVM vm = remap->vm; 757 757 758 758 SQInteger top = sq_gettop(vm); 759 - 759 + 760 760 sq_pushobject(vm, remap->reg); 761 761 sq_pushroottable(vm); 762 762 sq_pushinteger(vm, result->index); ··· 803 803 804 804 SQInteger top = sq_gettop(vm); 805 805 806 - if(top >= 3) 806 + if(top >= 3) 807 807 { 808 808 x = getSquirrelNumber(vm, 2); 809 809 y = getSquirrelNumber(vm, 3); ··· 839 839 } 840 840 } 841 841 } 842 - else 842 + else 843 843 { 844 844 colors[0] = getSquirrelNumber(vm, 8); 845 845 count = 1; ··· 867 867 sq_release(vm, &data.reg); 868 868 869 869 return 0; 870 - } 870 + } 871 871 } 872 872 } 873 873 } ··· 1020 1020 speed = getSquirrelNumber(vm, 7); 1021 1021 } 1022 1022 } 1023 - } 1023 + } 1024 1024 } 1025 1025 } 1026 1026 ··· 1118 1118 else 1119 1119 { 1120 1120 return sq_throwerror(vm, "invalid params, key [code]\n"); 1121 - } 1121 + } 1122 1122 1123 1123 return 1; 1124 1124 } ··· 1211 1211 { 1212 1212 sq_getstring(vm, -1, &text); 1213 1213 } 1214 - 1214 + 1215 1215 return (const char*)text; 1216 1216 } 1217 1217 ··· 1255 1255 if(top >= 9) 1256 1256 { 1257 1257 scale = getSquirrelNumber(vm, 9); 1258 - 1258 + 1259 1259 if (top >= 10) 1260 1260 { 1261 1261 SQBool b = SQFalse; 1262 1262 sq_getbool(vm, 10, &b); 1263 1263 alt = (b != SQFalse); 1264 1264 } 1265 - 1265 + 1266 1266 } 1267 1267 } 1268 1268 } ··· 1288 1288 { 1289 1289 SQInteger top = sq_gettop(vm); 1290 1290 1291 - if(top >= 2) 1291 + if(top >= 2) 1292 1292 { 1293 1293 tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; 1294 1294 ··· 1319 1319 if(top >= 7) 1320 1320 { 1321 1321 scale = getSquirrelNumber(vm, 7); 1322 - 1322 + 1323 1323 if (top >= 8) 1324 1324 { 1325 1325 SQBool b = SQFalse; ··· 1390 1390 1391 1391 sq_pushinteger(vm, val); 1392 1392 1393 - return 1; 1393 + return 1; 1394 1394 } 1395 1395 return sq_throwerror(vm, "invalid persistent tic index\n"); 1396 1396 } ··· 1402 1402 static SQInteger squirrel_time(HSQUIRRELVM vm) 1403 1403 { 1404 1404 tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; 1405 - 1405 + 1406 1406 sq_pushfloat(vm, (SQFloat)(core->api.time(tic))); 1407 1407 1408 1408 return 1; ··· 1411 1411 static SQInteger squirrel_tstamp(HSQUIRRELVM vm) 1412 1412 { 1413 1413 tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; 1414 - 1414 + 1415 1415 sq_pushinteger(vm, core->api.tstamp(tic)); 1416 1416 1417 1417 return 1; ··· 1421 1421 { 1422 1422 tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; 1423 1423 core->api.exit(tic); 1424 - 1424 + 1425 1425 return 0; 1426 1426 } 1427 1427 ··· 1499 1499 sq_getbool(vm, 4, &value); 1500 1500 1501 1501 core->api.fset(tic, index, flag, value); 1502 - return 0; 1502 + return 0; 1503 1503 } 1504 1504 } 1505 1505 } ··· 1583 1583 static void initAPI(tic_core* core) 1584 1584 { 1585 1585 HSQUIRRELVM vm = core->currentVM; 1586 - 1586 + 1587 1587 sq_setcompilererrorhandler(vm, squirrel_compilerError); 1588 - 1588 + 1589 1589 sq_pushregistrytable(vm); 1590 1590 sq_pushstring(vm, TicCore, -1); 1591 1591 sq_pushuserpointer(core->currentVM, core); ··· 1640 1640 1641 1641 sq_settop(vm, 0); 1642 1642 1643 - if((SQ_FAILED(sq_compilebuffer(vm, code, strlen(code), "squirrel", SQTrue))) || 1643 + if((SQ_FAILED(sq_compilebuffer(vm, code, strlen(code), "squirrel", SQTrue))) || 1644 1644 (sq_pushroottable(vm), false) || 1645 1645 (SQ_FAILED(sq_call(vm, 1, SQFalse, SQTrue)))) 1646 1646 { ··· 1651 1651 1652 1652 if (core->data) 1653 1653 core->data->error(core->data->data, errorString); 1654 - 1654 + 1655 1655 sq_pop(vm, 2); // error and error string 1656 1656 1657 1657 return false; ··· 1674 1674 1675 1675 if (core->data) 1676 1676 core->data->error(core->data->data, errorString); 1677 - sq_pop(vm, 3); // remove string, error and root table. 1677 + sq_pop(vm, 3); // remove string, error and root table. 1678 1678 } 1679 1679 1680 1680 static void callSquirrelTick(tic_mem* tic) ··· 1702 1702 { 1703 1703 sq_pushroottable(vm); 1704 1704 sq_pushstring(vm, OVR_FN, -1); 1705 - 1706 - if(SQ_SUCCEEDED(sq_get(vm, -2))) 1705 + 1706 + if(SQ_SUCCEEDED(sq_get(vm, -2))) 1707 1707 { 1708 1708 OVR(core) 1709 1709 { ··· 1712 1712 if(SQ_FAILED(sq_call(vm, 1, SQFalse, SQTrue))) 1713 1713 { 1714 1714 errorReport(tic); 1715 - } 1715 + } 1716 1716 } 1717 1717 } 1718 - else sq_poptop(vm); 1718 + else sq_poptop(vm); 1719 1719 } 1720 1720 #endif 1721 1721 } 1722 - else 1723 - { 1722 + else 1723 + { 1724 1724 sq_pop(vm, 1); 1725 1725 if (core->data) 1726 1726 core->data->error(core->data->data, "'function TIC()...' isn't found :("); ··· 1882 1882 return; 1883 1883 vm = core->currentVM; 1884 1884 } 1885 - 1885 + 1886 1886 sq_settop(vm, 0); 1887 1887 1888 - if((SQ_FAILED(sq_compilebuffer(vm, code, strlen(code), "squirrel", SQTrue))) || 1888 + if((SQ_FAILED(sq_compilebuffer(vm, code, strlen(code), "squirrel", SQTrue))) || 1889 1889 (sq_pushroottable(vm), false) || 1890 1890 (SQ_FAILED(sq_call(vm, 1, SQFalse, SQTrue)))) 1891 1891 { ··· 1910 1910 #include "../build/assets/squirrelmark.tic.dat" 1911 1911 }; 1912 1912 1913 - TIC_EXPORT const tic_script EXPORT_SCRIPT(Squirrel) = 1913 + TIC_EXPORT const tic_script EXPORT_SCRIPT(Squirrel) = 1914 1914 { 1915 1915 .id = 15, 1916 1916 .name = "squirrel",
+13 -13
src/api/wasm.c
··· 291 291 m3ApiGetArg (float, z1) 292 292 m3ApiGetArg (float, z2) 293 293 m3ApiGetArg (float, z3) 294 - m3ApiGetArg (bool, depth) 294 + m3ApiGetArg (bool, depth) 295 295 if (trans_colors == NULL) { 296 296 colorCount = 0; 297 297 } 298 298 299 299 tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; 300 - 301 - core->api.ttri(tic, x1, y1, x2, y2, x3, y3, 300 + 301 + core->api.ttri(tic, x1, y1, x2, y2, x3, y3, 302 302 u1, v1, u2, v2, u3, v3, texsrc, trans_colors, colorCount, z1, z2, z3, depth); 303 303 304 304 m3ApiSuccess(); ··· 365 365 366 366 // -1 is the "default" placeholder for index, hold, and period but the TIC side API 367 367 // knows this so we don't need to do any transaction, we can just pass the -1 values 368 - // straight thru 368 + // straight thru 369 369 370 370 m3ApiReturn(core->api.btnp((tic_mem *)core, index, hold, period)); 371 371 ··· 414 414 415 415 m3ApiGetArg (int32_t, sprite_index); 416 416 m3ApiGetArg (int8_t, flag); 417 - 417 + 418 418 tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; 419 419 420 420 m3ApiReturn(core->api.fget(tic, sprite_index, flag)); ··· 441 441 442 442 m3ApiGetArg (int32_t, x); 443 443 m3ApiGetArg (int32_t, y); 444 - 444 + 445 445 tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; 446 446 447 447 m3ApiReturn(core->api.mget(tic, x, y)); ··· 579 579 tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; 580 580 581 581 // read value 582 - if (value == -1) { 582 + if (value == -1) { 583 583 writeToStorage = false; 584 584 }; 585 585 ··· 590 590 u32 val = core->api.pmem(tic, address, value, writeToStorage); 591 591 m3ApiReturn(val); 592 592 } 593 - 593 + 594 594 m3ApiSuccess(); 595 595 } 596 596 ··· 683 683 684 684 *rdata->wasm_result = *result; 685 685 M3Result res = m3_CallV(fun, rdata->data, x, y, m3ApiPtrToOffset(rdata->wasm_result)); 686 - if (res) { 686 + if (res) { 687 687 rdata->core->data->error(rdata->core->data->data, res); 688 688 return; 689 689 } ··· 704 704 colorCount = 0; 705 705 } m3ApiGetArg (int8_t, scale) 706 706 m3ApiGetArg (i32, map_data_ptr) 707 - 707 + 708 708 709 709 tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; 710 710 // depends on their only being 1 module, which SHOULD:tm: be true ··· 716 716 info.wasm_result = (RemapResult*)m3ApiOffsetToPtr(map_data->res_ptr); 717 717 } 718 718 // defaults 719 - if (x == -1) { x = 0; } 719 + if (x == -1) { x = 0; } 720 720 if (y == -1) { y = 0; } 721 721 if (w == -1) { w = 30; } 722 722 if (h == -1) { h = 17; } ··· 791 791 m3ApiSuccess(); 792 792 } 793 793 794 - // audio 794 + // audio 795 795 796 796 // id [note] [duration=-1] [channel=0] [volume=15] [speed=0] 797 797 m3ApiRawFunction(wasmtic_sfx) ··· 810 810 if (channel >= 0 && channel < TIC_SOUND_CHANNELS) 811 811 { 812 812 core->api.sfx(tic, sfx_id, note, octave, duration, channel, volumeLeft & 0xf, volumeRight & 0xf, speed); 813 - } 813 + } 814 814 815 815 m3ApiSuccess(); 816 816 }
+6 -6
src/cart.c
··· 172 172 case CHUNK_FLAGS: LOAD_CHUNK(cart->banks[chunk->bank].flags); break; 173 173 case CHUNK_SCREEN: LOAD_CHUNK(cart->banks[chunk->bank].screen); break; 174 174 case CHUNK_LANG: LOAD_CHUNK(cart->lang); break; 175 - case CHUNK_BINARY: 175 + case CHUNK_BINARY: 176 176 binary[chunk->bank] = (struct BinaryChunk){chunkSize(chunk), ptr}; 177 177 break; 178 - case CHUNK_CODE: 178 + case CHUNK_CODE: 179 179 code[chunk->bank] = (struct CodeChunk){chunkSize(chunk), (char*)ptr}; 180 180 break; 181 181 #if defined(BUILD_DEPRECATED) ··· 191 191 { 192 192 if(image->width == TIC80_WIDTH && image->height == TIC80_HEIGHT) 193 193 for (s32 i = 0; i < TIC80_WIDTH * TIC80_HEIGHT; i++) 194 - tic_tool_poke4(cart->bank0.screen.data, i, 194 + tic_tool_poke4(cart->bank0.screen.data, i, 195 195 tic_nearest_color(cart->bank0.palette.vbank0.colors, (const tic_rgb*)&image->palette[image->buffer[i]], TIC_PALETTE_SIZE)); 196 196 197 197 gif_close(image); 198 198 } 199 199 } 200 200 break; 201 - case CHUNK_PATTERNS_DEP: 201 + case CHUNK_PATTERNS_DEP: 202 202 { 203 203 // workaround to load deprecated music patterns section 204 204 // and automatically convert volume value to a command ··· 330 330 } 331 331 332 332 const char* ptr; 333 - if (cart->binary.size) 333 + if (cart->binary.size) 334 334 { 335 335 ptr = cart->binary.data; 336 336 s32 remaining = cart->binary.size; 337 - for (s32 i = cart->binary.size / TIC_BANK_SIZE; i >= 0; --i, ptr += TIC_BANK_SIZE) 337 + for (s32 i = cart->binary.size / TIC_BANK_SIZE; i >= 0; --i, ptr += TIC_BANK_SIZE) 338 338 { 339 339 buffer = saveFixedChunk(buffer, CHUNK_BINARY, ptr, MIN(remaining, TIC_BANK_SIZE), i); 340 340 remaining -= TIC_BANK_SIZE;
+15 -15
src/core/core.c
··· 78 78 tic_core* core = (tic_core*)memory; 79 79 u8* ram = (u8*)memory->ram; 80 80 enum{RamBits = sizeof(tic_ram) * BITS_IN_BYTE}; 81 - 81 + 82 82 switch(bits) 83 83 { 84 84 case 1: if(address < RamBits / 1) tic_tool_poke1(ram, address, value); break; ··· 194 194 { 195 195 tic_core* core = (tic_core*)tic; 196 196 197 - static const struct { s32 bank; s32 ram; s32 size; u8 mask; } Sections[] = 198 - { 197 + static const struct { s32 bank; s32 ram; s32 size; u8 mask; } Sections[] = 198 + { 199 199 #define TIC_SYNC_DEF(CART, RAM, ...) { offsetof(tic_bank, CART), offsetof(tic_ram, RAM), sizeof(tic_##CART), tic_sync_##CART }, 200 - TIC_SYNC_LIST(TIC_SYNC_DEF) 200 + TIC_SYNC_LIST(TIC_SYNC_DEF) 201 201 #undef TIC_SYNC_DEF 202 202 }; 203 203 ··· 229 229 { 230 230 sync(tic->ram->data + Sections[i].ram, (u8*)bankPtr + Sections[i].bank, size, toCart); 231 231 } 232 - } 232 + } 233 233 } 234 234 235 235 core->state.synced |= mask; ··· 301 301 static void font2ram(tic_mem* memory) 302 302 { 303 303 memory->ram->font = (tic_font) { 304 - .regular = 304 + .regular = 305 305 { 306 - .data = 306 + .data = 307 307 { 308 308 #include "font.inl" 309 309 }, 310 310 { 311 311 { 312 - .width = TIC_FONT_WIDTH, 312 + .width = TIC_FONT_WIDTH, 313 313 .height = TIC_FONT_HEIGHT, 314 314 } 315 - } 315 + } 316 316 }, 317 317 318 - .alt = 318 + .alt = 319 319 { 320 - .data = 320 + .data = 321 321 { 322 322 #include "altfont.inl" 323 323 }, 324 324 { 325 325 { 326 - .width = TIC_ALTFONT_WIDTH, 327 - .height = TIC_FONT_HEIGHT, 326 + .width = TIC_ALTFONT_WIDTH, 327 + .height = TIC_FONT_HEIGHT, 328 328 } 329 329 } 330 330 }, ··· 567 567 568 568 core->state.gamepads.previous.data = input->gamepads.data; 569 569 // SECURITY: we do not use `memory.ram.input` here because it is 570 - // untrustworthy since the cartridge could have modified it to 570 + // untrustworthy since the cartridge could have modified it to 571 571 // inject artificial keyboard/gamepad events. 572 572 core->state.keyboard.previous.data = core->state.keyboard.now.data; 573 573 core->state.gamepads.previous.data = core->state.gamepads.now.data; ··· 677 677 s32 offsetX1 = vbank1(core)->vars.offset.x; 678 678 679 679 for(s32 x = TIC80_WIDTH; x != 2 * TIC80_WIDTH; ++x) 680 - *rowPtr++ = blitpix(tic, (x + offsetX0) % TIC80_WIDTH + start0, 680 + *rowPtr++ = blitpix(tic, (x + offsetX0) % TIC80_WIDTH + start0, 681 681 (x + offsetX1) % TIC80_WIDTH + start1, &pal0, &pal1); 682 682 } 683 683
+3 -3
src/core/core.h
··· 106 106 u32 holds[sizeof(tic80_gamepads) * BITS_IN_BYTE]; 107 107 } gamepads; 108 108 109 - struct 109 + struct 110 110 { 111 111 tic80_keyboard previous; 112 112 tic80_keyboard now; ··· 151 151 152 152 tic_tick tick; 153 153 tic_blit_callback callback; 154 - 154 + 155 155 u32 synced; 156 156 157 157 struct ··· 181 181 struct blip_t* left; 182 182 struct blip_t* right; 183 183 } blip; 184 - 184 + 185 185 s32 samplerate; 186 186 tic_tick_data* data; 187 187 tic_core_state_data state;
+27 -27
src/core/draw.c
··· 512 512 s64 dx = 4 * (1 - a) * b * b, dy = 4 * (b1 + 1) * a * a; /* error increment */ 513 513 s64 err = dx + dy + b1 * a * a, e2; /* error of 1.step */ 514 514 515 - if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped pos32s */ 515 + if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped pos32s */ 516 516 if (y0 > y1) y0 = y1; /* .. exchange them */ 517 517 y0 += (b + 1) / 2; y1 = y0 - b1; /* starting pixel */ 518 518 a *= 8 * a; b1 = 8 * b * b; 519 519 520 - do 520 + do 521 521 { 522 522 pix(memory, x1, y0, color); /* I. Quadrant */ 523 523 pix(memory, x0, y0, color); /* II. Quadrant */ 524 524 pix(memory, x0, y1, color); /* III. Quadrant */ 525 525 pix(memory, x1, y1, color); /* IV. Quadrant */ 526 526 e2 = 2 * err; 527 - if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */ 527 + if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */ 528 528 if (e2 >= dx || 2 * err > dy) { x0++; x1--; err += dx += b1; } /* x step */ 529 529 } while (x0 <= x1); 530 530 531 - while (y0-y1 < b) 531 + while (y0-y1 < b) 532 532 { /* too early stop of flat ellipses a=1 */ 533 533 pix(memory, x0 - 1, y0, color); /* -> finish tip of ellipse */ 534 - pix(memory, x1 + 1, y0++, color); 534 + pix(memory, x1 + 1, y0++, color); 535 535 pix(memory, x0 - 1, y1, color); 536 - pix(memory, x1 + 1, y1--, color); 536 + pix(memory, x1 + 1, y1--, color); 537 537 } 538 538 } 539 539 ··· 555 555 s32 yt = MAX(core->state.clip.t, y0); 556 556 s32 yb = MIN(core->state.clip.b, y1 + 1); 557 557 u8 final_color = mapColor(&core->memory, color); 558 - for (s32 y = yt; y < yb; y++) 558 + for (s32 y = yt; y < yb; y++) 559 559 { 560 560 s32 xl = MAX(SidesBuffer.Left[y], core->state.clip.l); 561 561 s32 xr = MIN(SidesBuffer.Right[y] + 1, core->state.clip.r); ··· 638 638 double d[3]; 639 639 } Vec3; 640 640 641 - typedef struct 641 + typedef struct 642 642 { 643 643 void* data; 644 644 const Vec2* v[3]; ··· 687 687 Vec2 p = {min.x + Center, min.y + Center}; 688 688 689 689 s32 c = (i + 1) % 3, n = (i + 2) % 3; 690 - 690 + 691 691 d[i].x = (a.v[c]->y - a.v[n]->y) / area; 692 692 d[i].y = (a.v[n]->x - a.v[c]->x) / area; 693 693 s.d[i] = edgeFn(a.v[c], a.v[n], &p) / area; ··· 724 724 drawTri(tic, 725 725 &(Vec2){x1, y1}, 726 726 &(Vec2){x2, y2}, 727 - &(Vec2){x3, y3}, 727 + &(Vec2){x3, y3}, 728 728 triColorShader, &color); 729 729 } 730 730 ··· 779 779 vars->y += a->w.d[i] * t->d.y; 780 780 } 781 781 782 - if(data->depth) 783 - vars->x /= vars->z, 782 + if(data->depth) 783 + vars->x /= vars->z, 784 784 vars->y /= vars->z; 785 785 786 786 return true; ··· 843 843 return shaderEnd(a, &vars, pixel, data->mapping[tic_tool_peek4(data->vram->data, iv * TIC80_WIDTH + iu)]); 844 844 } 845 845 846 - void tic_api_ttri(tic_mem* tic, 847 - float x1, float y1, 848 - float x2, float y2, 849 - float x3, float y3, 850 - float u1, float v1, 851 - float u2, float v2, 852 - float u3, float v3, 853 - tic_texture_src texsrc, u8* colors, s32 count, 846 + void tic_api_ttri(tic_mem* tic, 847 + float x1, float y1, 848 + float x2, float y2, 849 + float x3, float y3, 850 + float u1, float v1, 851 + float u2, float v2, 852 + float u3, float v3, 853 + tic_texture_src texsrc, u8* colors, s32 count, 854 854 float z1, float z2, float z3, bool depth) 855 855 { 856 856 // do not use depth if user passed z=0.0 857 857 if(z1 < FLT_EPSILON || z2 < FLT_EPSILON || z3 < FLT_EPSILON) 858 858 depth = false; 859 859 860 - TexData texData = 860 + TexData texData = 861 861 { 862 862 .sheet = getTileSheetFromSegment(tic, tic->ram->vram.blit.segment), 863 863 .mapping = getPalette(tic, colors, count), ··· 866 866 .depth = depth, 867 867 }; 868 868 869 - TexVert t[] = 869 + TexVert t[] = 870 870 { 871 871 {x1, y1, u1, v1, z1}, 872 872 {x2, y2, u2, v2, z2}, ··· 875 875 876 876 if(depth) 877 877 for(s32 i = 0; i != COUNT_OF(t); ++i) 878 - t[i].d.x /= t[i].d.z, 879 - t[i].d.y /= t[i].d.z, 878 + t[i].d.x /= t[i].d.z, 879 + t[i].d.y /= t[i].d.z, 880 880 t[i].d.z = 1.0 / t[i].d.z; 881 881 882 - static const PixelShader Shaders[] = 882 + static const PixelShader Shaders[] = 883 883 { 884 884 [tic_tiles_texture] = triTexTileShader, 885 885 [tic_map_texture] = triTexMapShader, 886 886 [tic_vbank_texture] = triTexVbankShader, 887 887 }; 888 - 888 + 889 889 if(texsrc >= 0 && texsrc < COUNT_OF(Shaders)) 890 890 drawTri(tic, 891 891 (const Vec2*)&t[0], 892 892 (const Vec2*)&t[1], 893 - (const Vec2*)&t[2], 893 + (const Vec2*)&t[2], 894 894 Shaders[texsrc], &texData); 895 895 } 896 896
+1 -1
src/core/io.c
··· 127 127 128 128 tic_point tic_api_mouse(tic_mem* memory) 129 129 { 130 - return memory->ram->input.mouse.relative 130 + return memory->ram->input.mouse.relative 131 131 ? (tic_point){memory->ram->input.mouse.rx, memory->ram->input.mouse.ry} 132 132 : (tic_point){memory->ram->input.mouse.x - TIC80_OFFSET_LEFT, memory->ram->input.mouse.y - TIC80_OFFSET_TOP}; 133 133 }
+3 -3
src/script.c
··· 75 75 76 76 #endif 77 77 78 - static const tic_script *Scripts[MAX_SUPPORTED_LANGS + 1] = 78 + static const tic_script *Scripts[MAX_SUPPORTED_LANGS + 1] = 79 79 { 80 80 #if defined(TIC_RUNTIME_STATIC) 81 81 #if defined (TIC_BUILD_WITH_LUA) ··· 131 131 { 132 132 const tic_script* script1 = *(const tic_script**)a; 133 133 const tic_script* script2 = *(const tic_script**)b; 134 - 134 + 135 135 if (script1->id < script2->id) return -1; 136 136 if (script1->id > script2->id) return 1; 137 137 return 0; ··· 167 167 { 168 168 FOREACH_LANG(script) 169 169 { 170 - if(script->id == memory->cart.lang 170 + if(script->id == memory->cart.lang 171 171 || strcmp(tic_tool_metatag(memory->cart.code.data, "script", script->singleComment), script->name) == 0) 172 172 return script; 173 173 }
+4 -4
src/studio/config.c
··· 39 39 40 40 #define JSON(...) #__VA_ARGS__ 41 41 42 - static void readConfig(Config* config) 42 + static void readConfig(Config* config) 43 43 { 44 44 const char* json = config->cart->code.data; 45 45 ··· 87 87 { 88 88 .cart = config->cart, 89 89 .uiScale = 4, 90 - .options = 90 + .options = 91 91 { 92 92 #if defined(CRT_SHADER_SUPPORT) 93 93 .crt = false, ··· 219 219 220 220 free(data); 221 221 } 222 - else saveConfig(config, false); 222 + else saveConfig(config, false); 223 223 } 224 224 225 225 loadOptions(config); ··· 267 267 "tabSize":%i 268 268 #endif 269 269 }) 270 - , 270 + , 271 271 #if defined(CRT_SHADER_SUPPORT) 272 272 bool2str(options->crt), 273 273 #endif
+103 -103
src/studio/editors/code.c
··· 89 89 90 90 if (first_change != NULL) { 91 91 92 - //we actually will want to go the one before the first change, as if 92 + //we actually will want to go the one before the first change, as if 93 93 //we were about to make the change 94 94 //ternary to make sure we don't go one before the beginning 95 - if (pos_undo) 95 + if (pos_undo) 96 96 code->cursor.position = first_change == code->src ? code->src : (first_change - 1); 97 97 98 98 else code->cursor.position = stored_pos; ··· 124 124 if(size <= delta) return tic_color_yellow; 125 125 if(size <= delta*2) return tic_color_orange; 126 126 return tic_color_red; 127 - } 127 + } 128 128 129 129 return tic_color_white; 130 130 } ··· 156 156 } 157 157 158 158 tic_api_print(code->tic, code->status.line, 0, StatusY, getConfig(code->studio)->theme.code.BG, true, 1, false); 159 - tic_api_print(code->tic, code->status.size, TIC80_WIDTH - (s32)strlen(code->status.size) * TIC_FONT_WIDTH, 159 + tic_api_print(code->tic, code->status.size, TIC80_WIDTH - (s32)strlen(code->status.size) * TIC_FONT_WIDTH, 160 160 StatusY, getConfig(code->studio)->theme.code.BG, true, 1, false); 161 161 } 162 162 ··· 169 169 if(*ptr++ == '\n') y++; 170 170 } 171 171 172 - return ptr; 172 + return ptr; 173 173 } 174 174 175 175 static char* getNextLineByPos(Code* code, char* pos) ··· 254 254 tic_api_print(tic, (char[]){symbol, '\0'}, x, y, color, true, 1, alt); 255 255 } 256 256 257 - static int drawTab(Code* code, s32 x, s32 y, u8 color) 257 + static int drawTab(Code* code, s32 x, s32 y, u8 color) 258 258 { 259 259 tic_mem* tic = code->tic; 260 260 s32 tab_size = getConfig(code->studio)->options.tabSize; ··· 263 263 while (count < tab_size) { 264 264 drawChar(tic, '\t', x, y, color, code->altFont); 265 265 count++; 266 - if (x / getFontWidth(code) % tab_size == 0) 266 + if (x / getFontWidth(code) % tab_size == 0) 267 267 break; 268 268 x += getFontWidth(code); 269 269 } ··· 313 313 const u8* colors = (const u8*)&getConfig(code->studio)->theme.code; 314 314 const CodeState* syntaxPointer = code->state; 315 315 316 - struct { char* start; char* end; } selection = 316 + struct { char* start; char* end; } selection = 317 317 { 318 318 MIN(code->cursor.selection, code->cursor.position), 319 319 MAX(code->cursor.selection, code->cursor.position) ··· 345 345 drawChar(code->tic, symbol, x, y, tic_color_dark_grey, code->altFont); 346 346 } 347 347 } 348 - else 348 + else 349 349 { 350 350 if(code->shadowText) 351 351 drawChar(code->tic, symbol, x+1, y+1, 0, code->altFont); ··· 598 598 while(true) 599 599 { 600 600 const char* pos = strchr(blockStart, *blockStdStringStart); 601 - 601 + 602 602 if(pos) 603 603 { 604 604 if(*(pos-1) == '\\' && *(pos-2) != '\\') blockStart = pos + 1; ··· 675 675 char c = *ptr; 676 676 677 677 if(isdigit(c)) ptr++; 678 - else if(numberStart[0] == '0' 679 - && (numberStart[1] == 'x' || numberStart[1] == 'X') 678 + else if(numberStart[0] == '0' 679 + && (numberStart[1] == 'x' || numberStart[1] == 'X') 680 680 && isxdigit(numberStart[2])) 681 681 { 682 682 if((ptr - numberStart < 2) || isxdigit(c)) ptr++; ··· 974 974 { 975 975 char* start = code->src; 976 976 int nesting = 0; 977 - 977 + 978 978 while (pos >= start) 979 979 { 980 980 if (isopenparen_(code, *pos)) ··· 1208 1208 // only allow deletion when string is empty 1209 1209 return true; 1210 1210 } 1211 - 1211 + 1212 1212 return false; 1213 1213 } 1214 1214 ··· 1283 1283 { 1284 1284 char* lineend = pos+1; 1285 1285 const char* end = code->src + strlen(code->src); 1286 - 1286 + 1287 1287 while (lineend < end) 1288 1288 { 1289 1289 if (islineend(*lineend)) break; ··· 1298 1298 char* linestart = code->cursor.position; 1299 1299 char* lineend = linestart+1; 1300 1300 const char* end = code->src + strlen(code->src); 1301 - 1301 + 1302 1302 if (shouldUseStructuredEdit(code)) 1303 1303 { 1304 1304 if (islineend(*linestart) || islineend(*lineend)) ··· 1345 1345 free(clipboard); 1346 1346 } 1347 1347 1348 - 1348 + 1349 1349 deleteCode(code, linestart, lineend); 1350 1350 code->cursor.position = linestart; 1351 1351 history(code); ··· 1462 1462 1463 1463 if (killSelection) 1464 1464 code->cursor.selection = NULL; 1465 - 1465 + 1466 1466 //no call to history because it gets called in replaceSelection 1467 1467 } 1468 1468 ··· 1595 1595 { 1596 1596 char* cursor_position = code->cursor.position; 1597 1597 char* cursor_selection = code->cursor.selection; 1598 - 1598 + 1599 1599 bool has_selection = cursor_selection && cursor_selection != cursor_position; 1600 1600 bool modifier_key_pressed = shift || crtl; 1601 - 1601 + 1602 1602 if(has_selection || modifier_key_pressed) 1603 1603 { 1604 1604 char* start; 1605 1605 char* end; 1606 - 1606 + 1607 1607 bool changed = false; 1608 - 1608 + 1609 1609 if(cursor_selection) { 1610 1610 start = MIN(cursor_selection, cursor_position); 1611 1611 end = MAX(cursor_selection, cursor_position); ··· 1630 1630 end += insertTab(code, line, line); 1631 1631 changed = true; 1632 1632 } 1633 - 1633 + 1634 1634 line = getNextLineByPos(code, line); 1635 1635 if(line >= end) break; 1636 1636 } 1637 - 1637 + 1638 1638 if(changed) { 1639 - 1640 - if(has_selection) 1639 + 1640 + if(has_selection) 1641 1641 { 1642 1642 code->cursor.position = start; 1643 1643 code->cursor.selection = end; 1644 1644 } 1645 1645 else if (start <= end) code->cursor.position = end; 1646 - 1646 + 1647 1647 history(code); 1648 1648 update(code); 1649 1649 } 1650 1650 } 1651 - else 1651 + else 1652 1652 { 1653 1653 char* line = getLineByPos(code, code->cursor.position); 1654 1654 code->cursor.position += insertTab(code, line, code->cursor.position); ··· 1844 1844 item->pos = ptr; 1845 1845 item->size = getLineSize(ptr); 1846 1846 } 1847 - 1847 + 1848 1848 ptr++; 1849 1849 state++; 1850 1850 } ··· 2017 2017 { 2018 2018 if (!shouldUseStructuredEdit(code)) 2019 2019 return; 2020 - 2020 + 2021 2021 const char* start = code->src; 2022 2022 char* pos = code->cursor.position; 2023 2023 const char* end = code->src + strlen(code->src); ··· 2162 2162 return false; 2163 2163 } 2164 2164 2165 - static bool clipboardHasNewline() 2165 + static bool clipboardHasNewline() 2166 2166 { 2167 2167 bool found = false; 2168 - if (tic_sys_clipboard_has()) 2168 + if (tic_sys_clipboard_has()) 2169 2169 { 2170 2170 2171 2171 //from what I can see in other usage, this should be a ··· 2173 2173 char* clipboard = tic_sys_clipboard_get(); 2174 2174 2175 2175 char* c = clipboard; 2176 - while(*c != 0) 2176 + while(*c != 0) 2177 2177 { 2178 - if (*c == '\n') 2178 + if (*c == '\n') 2179 2179 { 2180 2180 found = true; 2181 2181 break; ··· 2262 2262 updateEditor(code); 2263 2263 } 2264 2264 2265 - static void seekForward(Code* code, char sought) 2265 + static void seekForward(Code* code, char sought) 2266 2266 { 2267 2267 char* start = code->cursor.position; 2268 2268 code->cursor.position++; 2269 2269 while( 2270 - *code->cursor.position != sought 2271 - && *code->cursor.position != '\n' 2270 + *code->cursor.position != sought 2271 + && *code->cursor.position != '\n' 2272 2272 && *code->cursor.position != '\0' 2273 2273 ) 2274 2274 code->cursor.position++; ··· 2279 2279 updateEditor(code); 2280 2280 2281 2281 } 2282 - static void seekBackward(Code* code, char sought) 2282 + static void seekBackward(Code* code, char sought) 2283 2283 { 2284 2284 char* start = code->cursor.position; 2285 2285 code->cursor.position--; 2286 2286 while( 2287 - code->cursor.position > code->src 2288 - && *code->cursor.position != sought 2287 + code->cursor.position > code->src 2288 + && *code->cursor.position != sought 2289 2289 && *code->cursor.position != '\n' 2290 2290 ) 2291 2291 code->cursor.position--; ··· 2298 2298 } 2299 2299 2300 2300 static void findNextPopupText(Code* code) { 2301 - if (*code->popup.text) 2301 + if (*code->popup.text) 2302 2302 { 2303 2303 char* pos = downStrStr(code->src, code->cursor.position, code->popup.text); 2304 2304 if (pos == code->cursor.position) ··· 2316 2316 } 2317 2317 } 2318 2318 2319 - static bool processViPosition(Code* code, bool ctrl, bool alt, bool shift) 2319 + static bool processViPosition(Code* code, bool ctrl, bool alt, bool shift) 2320 2320 { 2321 2321 bool clear = !(shift || ctrl || alt); 2322 2322 ··· 2351 2351 else if (shift && keyWasPressed(code->studio, tic_key_6)) 2352 2352 { 2353 2353 goHome(code); 2354 - while (*code->cursor.position == ' ' || *code->cursor.position == '\t') 2354 + while (*code->cursor.position == ' ' || *code->cursor.position == '\t') 2355 2355 code->cursor.position++; 2356 2356 } 2357 2357 ··· 2370 2370 else if (shift && keyWasPressed(code->studio, tic_key_5)) 2371 2371 { 2372 2372 const char* pos = findMatchedDelim(code, code->cursor.position); 2373 - if (pos != NULL) 2373 + if (pos != NULL) 2374 2374 { 2375 2375 code->cursor.position = (char*) pos; 2376 2376 updateColumn(code); ··· 2396 2396 } 2397 2397 2398 2398 static void updateGotoCode(Code* code); 2399 - static void processViGoto(Code* code, s32 initial) 2399 + static void processViGoto(Code* code, s32 initial) 2400 2400 { 2401 2401 setCodeMode(code, TEXT_GOTO_MODE); 2402 2402 code->popup.text[0] = '0' + initial; ··· 2405 2405 } 2406 2406 2407 2407 static char* findStringStart(Code* code, char* pos) { 2408 - char sentinel = *pos; 2408 + char sentinel = *pos; 2409 2409 2410 2410 char* target = pos; //we will scan to the given position 2411 2411 pos = getLineByPos(code, pos); //from the beginning of the line 2412 2412 char* start = NULL; 2413 - 2413 + 2414 2414 //goto state machine! 2415 2415 start: 2416 2416 if(pos == target) goto end; 2417 2417 else if(*pos == '\\') { pos++; goto escape; } 2418 - else if (*pos == sentinel) 2419 - { 2420 - start=start?NULL:pos; 2421 - pos++; 2418 + else if (*pos == sentinel) 2419 + { 2420 + start=start?NULL:pos; 2421 + pos++; 2422 2422 goto start; 2423 2423 } 2424 2424 else { pos++; goto start; } ··· 2431 2431 2432 2432 static char* findStringEnd(char* pos) { 2433 2433 char sentinel = *pos; //can handle single or double quotes 2434 - //or anything else I guess 2434 + //or anything else I guess 2435 2435 if (*pos == '\0') goto end; 2436 2436 else pos++; //move past the sentinel so we don't immediately detect the end 2437 2437 ··· 2501 2501 code->cursor.position++; 2502 2502 } 2503 2503 } 2504 - //if on a quotation seek to change within the quotation 2505 - else if(*code->cursor.position == '"' || *code->cursor.position == '\'') 2504 + //if on a quotation seek to change within the quotation 2505 + else if(*code->cursor.position == '"' || *code->cursor.position == '\'') 2506 2506 { 2507 2507 char* start = findStringStart(code, code->cursor.position); 2508 2508 if (start == NULL) start = code->cursor.position; ··· 2511 2511 deleteCode(code, start, end); 2512 2512 code->cursor.position = start; 2513 2513 } 2514 - else if(!isalnum_(code, *code->cursor.position)) 2514 + else if(!isalnum_(code, *code->cursor.position)) 2515 2515 deleteChar(code); 2516 2516 else //change the word under the cursor 2517 2517 { 2518 2518 //only call left word if we are not already on the word border 2519 2519 if ( 2520 - code->cursor.position > code->src 2520 + code->cursor.position > code->src 2521 2521 && isalnum_(code, *(code->cursor.position-1)) 2522 2522 ) 2523 2523 leftWord(code); ··· 2534 2534 return c; 2535 2535 } 2536 2536 2537 - static void processViKeyboard(Code* code) 2537 + static void processViKeyboard(Code* code) 2538 2538 { 2539 2539 2540 2540 tic_mem* tic = code->tic; ··· 2571 2571 history(code); //needs to come after the mode switch or won't be honored 2572 2572 } 2573 2573 2574 - else if (keyWasPressed(code->studio, tic_key_backspace)) 2574 + else if (keyWasPressed(code->studio, tic_key_backspace)) 2575 2575 backspaceChar(code); 2576 2576 2577 - else if (keyWasPressed(code->studio, tic_key_tab)) 2577 + else if (keyWasPressed(code->studio, tic_key_tab)) 2578 2578 doTab(code, shift, ctrl); 2579 2579 2580 2580 else if (enterWasPressed(code->studio)) ··· 2589 2589 updateEditor(code); 2590 2590 } 2591 2591 } 2592 - } 2592 + } 2593 2593 else if(mode == VI_NORMAL) 2594 2594 { 2595 2595 bool processed = true; ··· 2598 2598 2599 2599 if (processViPosition(code, ctrl, alt, shift)); 2600 2600 2601 - else if (clear && keyWasPressed(code->studio, tic_key_i)) 2601 + else if (clear && keyWasPressed(code->studio, tic_key_i)) 2602 2602 setStudioViMode(code->studio, VI_INSERT); 2603 2603 2604 - else if (clear && keyWasPressed(code->studio, tic_key_a)) 2604 + else if (clear && keyWasPressed(code->studio, tic_key_a)) 2605 2605 { 2606 2606 setStudioViMode(code->studio, VI_INSERT); 2607 2607 rightColumn(code); 2608 2608 } 2609 - else if (clear && keyWasPressed(code->studio, tic_key_o)) 2609 + else if (clear && keyWasPressed(code->studio, tic_key_o)) 2610 2610 { 2611 2611 setStudioViMode(code->studio, VI_INSERT); 2612 2612 goEnd(code); 2613 2613 newLine(code); 2614 2614 } 2615 2615 2616 - else if (shift && keyWasPressed(code->studio, tic_key_o)) 2616 + else if (shift && keyWasPressed(code->studio, tic_key_o)) 2617 2617 { 2618 2618 setStudioViMode(code->studio, VI_INSERT); 2619 2619 goHome(code); 2620 2620 newLine(code); 2621 2621 upLine(code); 2622 2622 } 2623 - else if (clear && keyWasPressed(code->studio, tic_key_space)) 2623 + else if (clear && keyWasPressed(code->studio, tic_key_space)) 2624 2624 { 2625 2625 size_t col = code->cursor.column; 2626 2626 goEnd(code); ··· 2628 2628 code->cursor.column = col; 2629 2629 upLine(code); 2630 2630 } 2631 - else if (shift && keyWasPressed(code->studio, tic_key_space)) 2631 + else if (shift && keyWasPressed(code->studio, tic_key_space)) 2632 2632 { 2633 2633 size_t col = code->cursor.column; 2634 2634 goHome(code); ··· 2640 2640 else if (clear && keyWasPressed(code->studio, tic_key_v)) 2641 2641 setStudioViMode(code->studio, VI_SELECT); 2642 2642 2643 - else if (clear && keyWasPressed(code->studio, tic_key_slash)) 2643 + else if (clear && keyWasPressed(code->studio, tic_key_slash)) 2644 2644 setCodeMode(code, TEXT_FIND_MODE); 2645 2645 2646 2646 else if(clear && keyWasPressed(code->studio, tic_key_n)) ··· 2660 2660 } 2661 2661 else if(shift && keyWasPressed(code->studio, tic_key_n)) 2662 2662 { 2663 - if (*code->popup.text) 2663 + if (*code->popup.text) 2664 2664 { 2665 2665 char* pos = upStrStr(code->src, code->cursor.position, code->popup.text); 2666 2666 if (pos == NULL) ··· 2694 2694 else if (clear && keyWasPressed(code->studio, tic_key_u)) undo(code); 2695 2695 else if (shift && keyWasPressed(code->studio, tic_key_u)) redo(code); 2696 2696 2697 - else if (clear && keyWasPressed(code->studio, tic_key_p)) 2697 + else if (clear && keyWasPressed(code->studio, tic_key_p)) 2698 2698 { 2699 - if (clipboardHasNewline()) 2699 + if (clipboardHasNewline()) 2700 2700 { 2701 2701 downLine(code); 2702 2702 goHome(code); ··· 2706 2706 } else copyFromClipboard(code, false); 2707 2707 } 2708 2708 2709 - else if (shift && keyWasPressed(code->studio, tic_key_p)) 2709 + else if (shift && keyWasPressed(code->studio, tic_key_p)) 2710 2710 { 2711 - if (clipboardHasNewline()) 2711 + if (clipboardHasNewline()) 2712 2712 { 2713 2713 goHome(code); 2714 2714 char* pos = code->cursor.position; ··· 2716 2716 code->cursor.position = pos; 2717 2717 } else copyFromClipboard(code, false); 2718 2718 } 2719 - else if (alt && keyWasPressed(code->studio, tic_key_f)) 2719 + else if (alt && keyWasPressed(code->studio, tic_key_f)) 2720 2720 code->altFont = !code->altFont; 2721 2721 2722 - else if (alt && keyWasPressed(code->studio, tic_key_s)) 2722 + else if (alt && keyWasPressed(code->studio, tic_key_s)) 2723 2723 code->shadowText = !code->shadowText; 2724 2724 2725 2725 else if (clear && keyWasPressed(code->studio, tic_key_1)) processViGoto(code, 1); ··· 2736 2736 2737 2737 else if (shift && keyWasPressed(code->studio, tic_key_m)) setCodeMode(code, TEXT_BOOKMARK_MODE); 2738 2738 else if (clear && keyWasPressed(code->studio, tic_key_m)) toggleBookmark(code, getLineByPos(code, code->cursor.position)); 2739 - else if (clear && keyWasPressed(code->studio, tic_key_comma)) 2739 + else if (clear && keyWasPressed(code->studio, tic_key_comma)) 2740 2740 { 2741 2741 if(!goPrevBookmark(code, getPrevLineByPos(code, code->cursor.position))) 2742 2742 goPrevBookmark(code, code->src + strlen(code->src)); ··· 2772 2772 else if (shift && keyWasPressed(code->studio, tic_key_r)) 2773 2773 runGame(code->studio); 2774 2774 2775 - else if (clear && keyWasPressed(code->studio, tic_key_c)) 2775 + else if (clear && keyWasPressed(code->studio, tic_key_c)) 2776 2776 { 2777 - setStudioViMode(code->studio, VI_INSERT); 2777 + setStudioViMode(code->studio, VI_INSERT); 2778 2778 processViChange(code); 2779 2779 } 2780 2780 2781 2781 else if (shift && keyWasPressed(code->studio, tic_key_c)) 2782 2782 { 2783 - setStudioViMode(code->studio, VI_INSERT); 2783 + setStudioViMode(code->studio, VI_INSERT); 2784 2784 char* start = code->cursor.position; 2785 2785 goEnd(code); 2786 2786 deleteCode(code, start, code->cursor.position); ··· 2807 2807 else if (keyWasPressed(code->studio, tic_key_escape)) 2808 2808 setStudioViMode(code->studio, VI_NORMAL); 2809 2809 2810 - else if (clear && keyWasPressed(code->studio, tic_key_minus)) 2810 + else if (clear && keyWasPressed(code->studio, tic_key_minus)) 2811 2811 { 2812 2812 commentLine(code); 2813 2813 setStudioViMode(code->studio, VI_NORMAL); 2814 2814 } 2815 2815 2816 - else if (clear && keyWasPressed(code->studio, tic_key_y)) 2816 + else if (clear && keyWasPressed(code->studio, tic_key_y)) 2817 2817 { 2818 2818 copyToClipboard(code, false); 2819 2819 setStudioViMode(code->studio, VI_NORMAL); 2820 2820 } 2821 - else if (clear && keyWasPressed(code->studio, tic_key_d)) 2821 + else if (clear && keyWasPressed(code->studio, tic_key_d)) 2822 2822 { 2823 2823 cutToClipboard(code, false); 2824 2824 setStudioViMode(code->studio, VI_NORMAL); 2825 2825 } 2826 - else if (clear && keyWasPressed(code->studio, tic_key_p)) 2826 + else if (clear && keyWasPressed(code->studio, tic_key_p)) 2827 2827 { 2828 2828 copyFromClipboard(code, false); 2829 2829 setStudioViMode(code->studio, VI_NORMAL); ··· 2842 2842 else if (shift && keyWasPressed(code->studio, tic_key_period)) 2843 2843 doTab(code, false, true); 2844 2844 2845 - else if (clear && keyWasPressed(code->studio, tic_key_slash)) 2845 + else if (clear && keyWasPressed(code->studio, tic_key_slash)) 2846 2846 { 2847 2847 setStudioViMode(code->studio, VI_NORMAL); 2848 2848 setCodeMode(code, TEXT_FIND_MODE); ··· 2865 2865 2866 2866 if (processed) updateEditor(code); 2867 2867 2868 - } 2869 - else if (mode == VI_SEEK) 2868 + } 2869 + else if (mode == VI_SEEK) 2870 2870 { 2871 2871 2872 2872 if (keyWasPressed(code->studio, tic_key_escape)) ··· 2884 2884 } 2885 2885 } 2886 2886 } 2887 - else if (mode == VI_SEEK_BACK) 2887 + else if (mode == VI_SEEK_BACK) 2888 2888 { 2889 2889 2890 2890 if (keyWasPressed(code->studio, tic_key_escape)) ··· 2910 2910 2911 2911 enum KeybindMode keymode = getKeybindMode(code); 2912 2912 2913 - if (keymode == KEYBIND_VI) 2913 + if (keymode == KEYBIND_VI) 2914 2914 { 2915 2915 processViKeyboard(code); 2916 2916 return; 2917 2917 } 2918 2918 2919 - const bool emacsMode = keymode == KEYBIND_EMACS; 2919 + const bool emacsMode = keymode == KEYBIND_EMACS; 2920 2920 2921 2921 if (!emacsMode) 2922 2922 { ··· 2957 2957 } 2958 2958 2959 2959 bool usedKeybinding = true; 2960 - 2960 + 2961 2961 if(hasJustSwitchedToCodeMode(code->studio)) 2962 2962 { 2963 2963 setJustSwitchedToCodeMode(code->studio, false); 2964 2964 return; // Skip processing other inputs for this frame 2965 2965 } 2966 - 2966 + 2967 2967 // handle bookmarks 2968 2968 if(keyWasPressed(code->studio, tic_key_f1)) 2969 2969 { ··· 3100 3100 3101 3101 if(checkMousePos(code->studio, &rect)) 3102 3102 { 3103 - bool useDrag = (code->mode == TEXT_DRAG_CODE && checkMouseDown(code->studio, &rect, tic_mouse_left)) 3103 + bool useDrag = (code->mode == TEXT_DRAG_CODE && checkMouseDown(code->studio, &rect, tic_mouse_left)) 3104 3104 || checkMouseDown(code->studio, &rect, tic_mouse_right); 3105 3105 setCursor(code->studio, code->mode == TEXT_DRAG_CODE || useDrag ? tic_cursor_hand : tic_cursor_ibeam); 3106 3106 ··· 3124 3124 code->scroll.start.x = tic_api_mouse(tic).x + code->scroll.x * getFontWidth(code); 3125 3125 code->scroll.start.y = tic_api_mouse(tic).y + code->scroll.y * STUDIO_TEXT_HEIGHT; 3126 3126 } 3127 - else 3127 + else 3128 3128 { 3129 3129 if(checkMouseDblClick(code->studio, &rect, tic_mouse_left)) 3130 3130 { ··· 3173 3173 3174 3174 tic_api_cls(code->tic, getConfig(code->studio)->theme.code.BG); 3175 3175 3176 - drawCode(code, true); 3176 + drawCode(code, true); 3177 3177 drawStatus(code); 3178 3178 } 3179 3179 ··· 3206 3206 3207 3207 tic_api_cls(code->tic, getConfig(code->studio)->theme.code.BG); 3208 3208 3209 - drawCode(code, true); 3209 + drawCode(code, true); 3210 3210 drawStatus(code); 3211 3211 } 3212 3212 ··· 3306 3306 { 3307 3307 *code->popup.offset = 0; 3308 3308 code->popup.offset += strlen(" WITH:"); 3309 - //execute the replace 3309 + //execute the replace 3310 3310 3311 3311 //if we have a selection only replace within the selection 3312 3312 char* start = code->src; ··· 3325 3325 pos = downStrStr(code->src, pos, code->popup.text); 3326 3326 if (code->cursor.selection != NULL && pos > code->cursor.position) 3327 3327 break; 3328 - } 3328 + } 3329 3329 history(code); 3330 3330 updateEditor(code); 3331 3331 parseSyntaxColor(code); ··· 3338 3338 if(*code->popup.text && code->popup.offset == NULL) 3339 3339 { 3340 3340 code->popup.text[strlen(code->popup.text)-1] = '\0'; 3341 - } 3342 - else if (*code->popup.text) 3341 + } 3342 + else if (*code->popup.text) 3343 3343 { 3344 3344 if (strlen(code->popup.offset) - strlen(" WITH:") > 0) 3345 3345 code->popup.text[strlen(code->popup.text)-1] = '\0'; ··· 3464 3464 tic_api_rect(code->tic, rect.x - 1, rect.y + (code->sidebar.index - code->sidebar.scroll) * STUDIO_TEXT_HEIGHT, 3465 3465 rect.w + 1, TIC_FONT_HEIGHT + 2, tic_color_red); 3466 3466 3467 - for(const tic_outline_item* ptr = code->sidebar.items, *end = ptr + code->sidebar.size; 3467 + for(const tic_outline_item* ptr = code->sidebar.items, *end = ptr + code->sidebar.size; 3468 3468 ptr != end; ptr++, y += STUDIO_TEXT_HEIGHT) 3469 3469 { 3470 3470 // find the first non-space character ··· 3489 3489 3490 3490 static void normSidebarScroll(Code* code) 3491 3491 { 3492 - code->sidebar.scroll = code->sidebar.size > TEXT_BUFFER_HEIGHT 3492 + code->sidebar.scroll = code->sidebar.size > TEXT_BUFFER_HEIGHT 3493 3493 ? CLAMP(code->sidebar.scroll, 0, code->sidebar.size - TEXT_BUFFER_HEIGHT) : 0; 3494 3494 } 3495 3495 ··· 3544 3544 3545 3545 else if(enterWasPressed(code->studio)) 3546 3546 { 3547 - updateSidebarCode(code); 3547 + updateSidebarCode(code); 3548 3548 setCodeMode(code, TEXT_EDIT_MODE); 3549 3549 } 3550 3550 } ··· 3671 3671 { 3672 3672 tic_api_rect(code->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, tic_color_white); 3673 3673 3674 - static const struct Button {u8 icon; const char* tip;} Buttons[] = 3674 + static const struct Button {u8 icon; const char* tip;} Buttons[] = 3675 3675 { 3676 3676 {tic_icon_hand, "DRAG [right mouse]"}, 3677 3677 {tic_icon_find, "FIND [ctrl+f]"}, ··· 3708 3708 { 3709 3709 tic_api_rect(code->tic, rect.x, rect.y, Size, Size, tic_color_grey); 3710 3710 drawBitIcon(code->studio, btn->icon, rect.x, rect.y + 1, tic_color_black); 3711 - } 3711 + } 3712 3712 3713 3713 drawBitIcon(code->studio, btn->icon, rect.x, rect.y, active ? tic_color_white : (over ? tic_color_grey : tic_color_light_grey)); 3714 3714 }
+47 -47
src/studio/editors/map.c
··· 148 148 } 149 149 } 150 150 151 - drawBitIcon(map->studio, sheetVisible(map) ? tic_icon_up : tic_icon_down, rect.x, rect.y, 151 + drawBitIcon(map->studio, sheetVisible(map) ? tic_icon_up : tic_icon_down, rect.x, rect.y, 152 152 over ? tic_color_grey : tic_color_light_grey); 153 153 154 154 return x; ··· 210 210 if(sheetVisible(map)) 211 211 { 212 212 tic_rect rect = {TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, TOOLBAR_SIZE, TIC_SPRITESHEET_SIZE, TIC_SPRITESHEET_SIZE}; 213 - 213 + 214 214 if(checkMousePos(map->studio, &rect)) 215 215 { 216 216 s32 mx = tic_api_mouse(tic).x - rect.x; ··· 272 272 } 273 273 274 274 const char* label = (char[]){Labels[i], '\0'}; 275 - tic_api_print(tic, label, rect.x, rect.y, 276 - mode == map->sheet.blit.mode 277 - ? tic_color_dark_grey 278 - : hover 279 - ? tic_color_grey 280 - : tic_color_light_grey, 281 - true, 1, true); 275 + tic_api_print(tic, label, rect.x, rect.y, 276 + mode == map->sheet.blit.mode 277 + ? tic_color_dark_grey 278 + : hover 279 + ? tic_color_grey 280 + : tic_color_light_grey, 281 + true, 1, true); 282 282 } 283 283 } 284 284 ··· 312 312 } 313 313 } 314 314 315 - drawBitIcon(map->studio, Icons[i], rect.x, rect.y, 316 - i == map->sheet.blit.bank 317 - ? tic_color_dark_grey 318 - : hover 319 - ? tic_color_grey 315 + drawBitIcon(map->studio, Icons[i], rect.x, rect.y, 316 + i == map->sheet.blit.bank 317 + ? tic_color_dark_grey 318 + : hover 319 + ? tic_color_grey 320 320 : tic_color_light_grey); 321 321 } 322 322 } ··· 356 356 } 357 357 358 358 const char* label = (char[]){i + '1', '\0'}; 359 - tic_api_print(tic, label, rect.x + 1, rect.y + 1, 359 + tic_api_print(tic, label, rect.x + 1, rect.y + 1, 360 360 active 361 361 ? tic_color_white 362 - : hover 363 - ? tic_color_grey 364 - : tic_color_light_grey, 365 - true, 1, true); 366 - } 362 + : hover 363 + ? tic_color_grey 364 + : tic_color_light_grey, 365 + true, 1, true); 366 + } 367 367 } 368 368 369 369 static void drawMapToolbar(Map* map, s32 x, s32 y) ··· 390 390 x = drawPenButton(map, x, 0); 391 391 392 392 x = drawGridButton(map, x - 5, 0); 393 - drawWorldButton(map, x, 0); 393 + drawWorldButton(map, x, 0); 394 394 } 395 395 } 396 396 ··· 405 405 406 406 for(s32 i = 1; i < rect.h; i += 4) 407 407 { 408 - if (blit->page > 0) 408 + if (blit->page > 0) 409 409 { 410 410 tic_api_pix(tic, rect.x-1, rect.y + i, tic_color_black, false); 411 411 tic_api_pix(tic, rect.x-1, rect.y + i + 1, tic_color_black, false); 412 412 } 413 413 414 - if (blit->page < blit->pages - 1) 414 + if (blit->page < blit->pages - 1) 415 415 { 416 416 tic_api_pix(tic, rect.x+rect.w, rect.y + i, tic_color_black, false); 417 417 tic_api_pix(tic, rect.x+rect.w, rect.y + i + 1, tic_color_black, false); ··· 477 477 { 478 478 if(map->sheet.keep && map->sheet.drag) 479 479 map->anim.movie = resetMovie(&map->anim.hide); 480 - 480 + 481 481 map->sheet.drag = false; 482 482 } 483 483 } ··· 489 489 tic_blit blit = map->sheet.blit; 490 490 SCOPE(resetBlitMode(map->tic), tic_api_clip(tic, 0, 0, TIC80_WIDTH, TIC80_HEIGHT)) 491 491 { 492 - tic_point start = 492 + tic_point start = 493 493 { 494 494 x - blit.page * TIC_SPRITESHEET_SIZE + map->anim.pos.page, 495 495 y - blit.bank * TIC_SPRITESHEET_SIZE + map->anim.pos.bank ··· 684 684 { 685 685 tic_rect rect = {MAP_X, MAP_Y, MAP_WIDTH, MAP_HEIGHT}; 686 686 687 - processScrolling(map, checkMouseDown(map->studio, &rect, tic_mouse_left) || 687 + processScrolling(map, checkMouseDown(map->studio, &rect, tic_mouse_left) || 688 688 checkMouseDown(map->studio, &rect, tic_mouse_right)); 689 689 } 690 690 ··· 753 753 s32 index = data[i + j * w]; 754 754 s32 sx = index % TIC_SPRITESHEET_COLS; 755 755 s32 sy = index / TIC_SPRITESHEET_COLS; 756 - tic_api_spr(tic, sx + map->sheet.blit.pages * sy * TIC_SPRITESHEET_COLS, 756 + tic_api_spr(tic, sx + map->sheet.blit.pages * sy * TIC_SPRITESHEET_COLS, 757 757 mx + i * TIC_SPRITESIZE, my + j * TIC_SPRITESIZE, 1, 1, NULL, 0, 1, tic_no_flip, tic_no_rotate); 758 758 } 759 759 ··· 851 851 } 852 852 853 853 if(stack->head < (stack->data + FILL_STACK_SIZE-1)) 854 - { 854 + { 855 855 stack->head++; 856 856 stack->head->x = x; 857 857 stack->head->y = y; ··· 929 929 for(s32 i = 0; i < map->sheet.rect.w; i++) 930 930 tic_api_mset(map->tic, x+i, y+j, (mx+i) + (my+j) * TIC_SPRITESHEET_COLS); 931 931 932 - for(s32 i = 0; i < COUNT_OF(dx); i++) 932 + for(s32 i = 0; i < COUNT_OF(dx); i++) 933 933 { 934 934 s32 nx = x + dx[i]*map->sheet.rect.w; 935 935 s32 ny = y + dy[i]*map->sheet.rect.h; 936 936 937 - if(nx >= clip.l && nx < clip.r && ny >= clip.t && ny < clip.b) 937 + if(nx >= clip.l && nx < clip.r && ny >= clip.t && ny < clip.b) 938 938 { 939 939 bool match = true; 940 940 for(s32 j = 0; j < map->sheet.rect.h; j++) ··· 948 948 } 949 949 } 950 950 } 951 - } 951 + } 952 952 } 953 953 954 954 static s32 moduloWrap(s32 x, s32 m) ··· 1053 1053 { 1054 1054 if(j >= 0 && j < TIC80_HEIGHT) 1055 1055 for(s32 i = 0; i < TIC80_WIDTH; i++) 1056 - { 1056 + { 1057 1057 u8 color = tic_api_pix(tic, i, j, 0, true); 1058 1058 tic_api_pix(tic, i, j, (color+1)%TIC_PALETTE_SIZE, false); 1059 1059 } ··· 1082 1082 bool space = tic_api_key(tic, tic_key_space); 1083 1083 1084 1084 if(handle) 1085 - processScrolling(map, 1086 - ((space || map->mode == MAP_DRAG_MODE) && checkMouseDown(map->studio, &rect, tic_mouse_left)) || 1085 + processScrolling(map, 1086 + ((space || map->mode == MAP_DRAG_MODE) && checkMouseDown(map->studio, &rect, tic_mouse_left)) || 1087 1087 checkMouseDown(map->studio, &rect, tic_mouse_right)); 1088 1088 1089 1089 { ··· 1123 1123 tic_rect* sel = &map->select.rect; 1124 1124 1125 1125 if(sel->w > 0 && sel->h > 0) 1126 - { 1126 + { 1127 1127 s32 size = sel->w * sel->h + 2; 1128 1128 u8* buffer = malloc(size); 1129 1129 ··· 1142 1142 1143 1143 s32 index = x + y * TIC_MAP_WIDTH; 1144 1144 *ptr++ = map->src->data[index]; 1145 - } 1145 + } 1146 1146 1147 1147 toClipboard(buffer, size, true); 1148 - free(buffer); 1148 + free(buffer); 1149 1149 } 1150 1150 } 1151 1151 } ··· 1238 1238 } 1239 1239 1240 1240 if(tic->ram->input.keyboard.data == 0) return; 1241 - 1241 + 1242 1242 bool ctrl = tic_api_key(tic, tic_key_ctrl); 1243 1243 1244 1244 switch(getClipboardEvent(map->studio)) ··· 1248 1248 case TIC_CLIPBOARD_PASTE: copyFromClipboard(map); break; 1249 1249 default: break; 1250 1250 } 1251 - 1251 + 1252 1252 if(tic_api_key(tic, tic_key_alt)) 1253 1253 return; 1254 1254 ··· 1293 1293 processAnim(map->anim.movie, map); 1294 1294 1295 1295 // process scroll 1296 - if(tic->ram->input.mouse.scrolly < 0) 1296 + if(tic->ram->input.mouse.scrolly < 0) 1297 1297 { 1298 1298 setStudioMode(map->studio, TIC_WORLD_MODE); 1299 1299 return; ··· 1325 1325 { 1326 1326 tic_rect rect = {MAP_X, MAP_Y, MAP_WIDTH, MAP_HEIGHT}; 1327 1327 if(!sheetVisible(map) && checkMousePos(map->studio, &rect) && !tic_api_key(tic, tic_key_space)) 1328 - { 1328 + { 1329 1329 switch(map->mode) 1330 1330 { 1331 1331 case MAP_DRAW_MODE: ··· 1400 1400 .tick = tick, 1401 1401 .src = src, 1402 1402 .mode = MAP_DRAW_MODE, 1403 - .canvas = 1403 + .canvas = 1404 1404 { 1405 1405 .grid = true, 1406 1406 .draw = false, 1407 1407 .start = {0, 0}, 1408 1408 }, 1409 - .sheet = 1409 + .sheet = 1410 1410 { 1411 1411 .rect = {0, 0, 1, 1}, 1412 1412 .start = {0, 0}, 1413 1413 .drag = false, 1414 1414 .blit = {0}, 1415 1415 }, 1416 - .select = 1416 + .select = 1417 1417 { 1418 1418 .rect = {0, 0, 0, 0}, 1419 1419 .start = {0, 0}, ··· 1421 1421 }, 1422 1422 .paste = NULL, 1423 1423 .tickCounter = 0, 1424 - .scroll = 1424 + .scroll = 1425 1425 { 1426 - .x = 0, 1427 - .y = 0, 1426 + .x = 0, 1427 + .y = 0, 1428 1428 .active = false, 1429 1429 .gesture = false, 1430 1430 .start = {0, 0},
+85 -85
src/studio/editors/music.c
··· 375 375 static void pageUp(Music* music) 376 376 { 377 377 music->tracker.edit.y -= TRACKER_ROWS; 378 - if(music->tracker.edit.y < 0) 378 + if(music->tracker.edit.y < 0) 379 379 music->tracker.edit.y = 0; 380 380 381 381 updateTracker(music); ··· 388 388 music->tracker.edit.y += TRACKER_ROWS; 389 389 s32 rows = getRows(music); 390 390 391 - if(music->tracker.edit.y >= rows) 391 + if(music->tracker.edit.y >= rows) 392 392 music->tracker.edit.y = rows-1; 393 - 393 + 394 394 updateTracker(music); 395 395 } 396 396 ··· 685 685 memset(pattern->rows, 0, sizeof(tic_track_pattern)); 686 686 history_add(music->history); 687 687 } 688 - } 688 + } 689 689 } 690 690 } 691 691 ··· 713 713 714 714 memcpy(&header, data, HeaderSize); 715 715 716 - if(size == header.size * RowSize + HeaderSize 716 + if(size == header.size * RowSize + HeaderSize 717 717 && size == sizeof(tic_track_pattern) + HeaderSize) 718 718 { 719 719 memcpy(pattern->rows, data + HeaderSize, header.size * RowSize); ··· 765 765 } 766 766 767 767 resetSelection(music); 768 - } 768 + } 769 769 } 770 770 } 771 771 ··· 944 944 history_add(music->history); 945 945 946 946 if(music->tracker.select.rect.h <= 0) 947 - downRow(music); 947 + downRow(music); 948 948 } 949 949 } 950 950 ··· 1024 1024 if(index >= 0) 1025 1025 { 1026 1026 row->note = (index % NOTES) + NoteStart; 1027 - row->octave = index / NOTES; 1027 + row->octave = index / NOTES; 1028 1028 } 1029 1029 } 1030 1030 } ··· 1067 1067 bool shift = tic_api_key(tic, tic_key_shift); 1068 1068 bool ctrl = tic_api_key(tic, tic_key_ctrl); 1069 1069 1070 - static const struct Handler{u8 key; void(*handler)(Music* music); bool select; bool ctrl;} Handlers[] = 1070 + static const struct Handler{u8 key; void(*handler)(Music* music); bool select; bool ctrl;} Handlers[] = 1071 1071 { 1072 1072 {tic_key_up, upRow, true}, 1073 1073 {tic_key_down, downRow, true}, ··· 1145 1145 tic_key_y, 1146 1146 tic_key_7, 1147 1147 tic_key_u, 1148 - 1148 + 1149 1149 // extra keys 1150 1150 tic_key_i, 1151 1151 tic_key_9, ··· 1162 1162 { 1163 1163 case ColumnNote: 1164 1164 case ColumnSemitone: 1165 - if(keyWasPressedOnce(tic, tic_key_z) && shift) 1165 + if(keyWasPressedOnce(tic, tic_key_z) && shift) 1166 1166 music->last.octave -= 1; 1167 - else if(keyWasPressedOnce(tic, tic_key_x) && shift) 1167 + else if(keyWasPressedOnce(tic, tic_key_x) && shift) 1168 1168 music->last.octave += 1; 1169 1169 1170 1170 if (keyWasPressed(music->studio, tic_key_a)) ··· 1188 1188 downRow(music); 1189 1189 1190 1190 break; 1191 - } 1191 + } 1192 1192 } 1193 1193 } 1194 1194 break; ··· 1213 1213 if(getNote(music) >= 0) 1214 1214 { 1215 1215 s32 val = sym2dec(getKeyboardText(music->studio)); 1216 - 1216 + 1217 1217 if(val >= 0) 1218 1218 { 1219 1219 s32 sfx = setDigit(col == 3 ? 1 : 0, getSfx(music), val); ··· 1232 1232 if(sym) 1233 1233 { 1234 1234 const char* val = strchr(MusicCommands, toupper(sym)); 1235 - 1235 + 1236 1236 if(val) 1237 1237 setCommand(music, val - MusicCommands); 1238 1238 } ··· 1250 1250 : setParam2(music, val); 1251 1251 } 1252 1252 } 1253 - break; 1253 + break; 1254 1254 } 1255 1255 1256 1256 history_add(music->history); ··· 1276 1276 else if(keyWasPressed(music->studio, tic_key_tab)) nextPattern(music); 1277 1277 else if(keyWasPressed(music->studio, tic_key_left)) colLeft(music); 1278 1278 else if(keyWasPressed(music->studio, tic_key_right)) colRight(music); 1279 - else if(keyWasPressed(music->studio, tic_key_down) 1280 - || enterWasPressed(music->studio)) 1279 + else if(keyWasPressed(music->studio, tic_key_down) 1280 + || enterWasPressed(music->studio)) 1281 1281 music->tracker.edit.y = music->scroll.pos; 1282 1282 else 1283 1283 { ··· 1285 1285 1286 1286 if(val >= 0) 1287 1287 { 1288 - s32 pattern = setDigit(1 - music->tracker.col & 1, tic_tool_get_pattern_id(getTrack(music), 1288 + s32 pattern = setDigit(1 - music->tracker.col & 1, tic_tool_get_pattern_id(getTrack(music), 1289 1289 music->frame, channel), val); 1290 1290 1291 1291 if(pattern <= MUSIC_PATTERNS) ··· 1293 1293 setChannelPatternValue(music, pattern, music->frame, channel); 1294 1294 1295 1295 if(music->tracker.col == 0) 1296 - colRight(music); 1296 + colRight(music); 1297 1297 } 1298 1298 } 1299 1299 } ··· 1389 1389 case PianoChannel4Column: 1390 1390 switch (sym) 1391 1391 { 1392 - case '+': 1393 - case '-': 1394 - setChannelPattern(music, delta, music->piano.edit.x / 2); 1392 + case '+': 1393 + case '-': 1394 + setChannelPattern(music, delta, music->piano.edit.x / 2); 1395 1395 break; 1396 1396 } 1397 1397 1398 1398 if(dec >= 0) 1399 1399 { 1400 - s32 pattern = setDigit(1 - music->piano.edit.x & 1, 1400 + s32 pattern = setDigit(1 - music->piano.edit.x & 1, 1401 1401 tic_tool_get_pattern_id(getTrack(music), music->piano.edit.y, col), dec); 1402 1402 1403 1403 if(pattern <= MUSIC_PATTERNS) ··· 1412 1412 { 1413 1413 switch (sym) 1414 1414 { 1415 - case '+': 1416 - case '-': 1417 - tic_tool_set_track_row_sfx(row, tic_modulo(tic_tool_get_track_row_sfx(row) + delta, SFX_COUNT)); 1415 + case '+': 1416 + case '-': 1417 + tic_tool_set_track_row_sfx(row, tic_modulo(tic_tool_get_track_row_sfx(row) + delta, SFX_COUNT)); 1418 1418 break; 1419 1419 default: 1420 1420 if(dec >= 0) ··· 1541 1541 1542 1542 bool ctrl = tic_api_key(tic, tic_key_ctrl); 1543 1543 bool shift = tic_api_key(tic, tic_key_shift); 1544 - 1544 + 1545 1545 if(tic_api_key(tic, tic_key_alt)) 1546 1546 return; 1547 1547 ··· 1558 1558 1559 1559 if(keyWasPressed(music->studio, tic_key_space)) 1560 1560 { 1561 - stopped 1561 + stopped 1562 1562 ? playTrack(music) 1563 1563 : stopTrack(music); 1564 1564 } ··· 1566 1566 { 1567 1567 stopped 1568 1568 ? (shift 1569 - ? playTrackFromNow(music) 1569 + ? playTrackFromNow(music) 1570 1570 : playFrame(music)) 1571 1571 : stopTrack(music); 1572 1572 } ··· 1575 1575 switch (music->tab) 1576 1576 { 1577 1577 case MUSIC_TRACKER_TAB: 1578 - music->tracker.edit.y >= 0 1578 + music->tracker.edit.y >= 0 1579 1579 ? processTrackerKeyboard(music) 1580 1580 : processPatternKeyboard(music); 1581 1581 break; ··· 1848 1848 tic_mem* tic = music->tic; 1849 1849 1850 1850 enum{On=36, Off = 52, Width=7, Height=3}; 1851 - 1851 + 1852 1852 tic_rect rect = {x, y, Width, Height}; 1853 1853 1854 1854 if(checkMousePos(music->studio, &rect)) ··· 1898 1898 { 1899 1899 typedef struct 1900 1900 { 1901 - u8 icon; 1902 - const char* tip; 1903 - const char* alt; 1901 + u8 icon; 1902 + const char* tip; 1903 + const char* alt; 1904 1904 void(*handler)(Music*); 1905 1905 } Button; 1906 1906 1907 - static const Button FollowButton = 1907 + static const Button FollowButton = 1908 1908 { 1909 1909 tic_icon_follow, 1910 1910 "FOLLOW [ctrl+f]", ··· 1912 1912 toggleFollowMode, 1913 1913 }; 1914 1914 1915 - static const Button LoopButton = 1915 + static const Button LoopButton = 1916 1916 { 1917 1917 tic_icon_loop, 1918 1918 "LOOP", ··· 1920 1920 toggleLoopMode, 1921 1921 }; 1922 1922 1923 - static const Button SustainButton = 1923 + static const Button SustainButton = 1924 1924 { 1925 1925 tic_icon_sustain, 1926 1926 "SUSTAIN NOTES ...", ··· 1928 1928 toggleSustainMode, 1929 1929 }; 1930 1930 1931 - static const Button PlayFromNowButton = 1931 + static const Button PlayFromNowButton = 1932 1932 { 1933 1933 tic_icon_playnow, 1934 1934 "PLAY FROM NOW ...", ··· 1936 1936 playTrackFromNow, 1937 1937 }; 1938 1938 1939 - static const Button PlayFrameButton = 1939 + static const Button PlayFrameButton = 1940 1940 { 1941 1941 tic_icon_playframe, 1942 1942 "PLAY FRAME ...", ··· 1944 1944 playFrame, 1945 1945 }; 1946 1946 1947 - static const Button PlayTrackButton = 1947 + static const Button PlayTrackButton = 1948 1948 { 1949 1949 tic_icon_right, 1950 1950 "PLAY TRACK ...", ··· 1952 1952 playTrack, 1953 1953 }; 1954 1954 1955 - static const Button StopButton = 1955 + static const Button StopButton = 1956 1956 { 1957 1957 tic_icon_stop, 1958 1958 "STOP [enter]", ··· 1964 1964 1965 1965 if(checkPlaying(music)) 1966 1966 { 1967 - static const Button* Buttons[] = 1967 + static const Button* Buttons[] = 1968 1968 { 1969 - &LoopButton, 1970 - &FollowButton, 1969 + &LoopButton, 1970 + &FollowButton, 1971 1971 &SustainButton, 1972 1972 &StopButton, 1973 1973 }; ··· 1977 1977 } 1978 1978 else 1979 1979 { 1980 - static const Button* Buttons[] = 1980 + static const Button* Buttons[] = 1981 1981 { 1982 - &LoopButton, 1983 - &FollowButton, 1982 + &LoopButton, 1983 + &FollowButton, 1984 1984 &SustainButton, 1985 1985 &PlayFromNowButton, 1986 1986 &PlayFrameButton, ··· 2129 2129 s32 col = (tic_api_mouse(tic).x - rect.x) * TIC_SOUND_CHANNELS / rect.w; 2130 2130 s32 row = (tic_api_mouse(tic).y - rect.y) * MUSIC_FRAMES / rect.h; 2131 2131 2132 - // move edit cursor if pattern already selected only 2132 + // move edit cursor if pattern already selected only 2133 2133 if(col == music->piano.col && row == music->frame) 2134 2134 { 2135 2135 tic_point pos = {(tic_api_mouse(tic).x - rect.x) * TIC_SOUND_CHANNELS * 2 / rect.w, row}; ··· 2151 2151 2152 2152 for(s32 c = 0; c < TIC_SOUND_CHANNELS; c++) 2153 2153 { 2154 - tic_api_rect(tic, x + c * ColWidth, y + 1, 2154 + tic_api_rect(tic, x + c * ColWidth, y + 1, 2155 2155 ColWidth, MUSIC_FRAMES * TIC_FONT_HEIGHT + (Header - 1), c & 1 ? tic_color_black : tic_color_dark_grey); 2156 2156 2157 - tic_api_print(tic, (char[]){'1' + c, '\0'}, x + (ColWidth - (TIC_ALTFONT_WIDTH - 1)) / 2 + c * ColWidth, y + 2, 2157 + tic_api_print(tic, (char[]){'1' + c, '\0'}, x + (ColWidth - (TIC_ALTFONT_WIDTH - 1)) / 2 + c * ColWidth, y + 2, 2158 2158 tic_color_grey, true, 1, true); 2159 2159 2160 2160 ··· 2195 2195 static void drawStereoSeparator(Music* music, s32 x, s32 y) 2196 2196 { 2197 2197 tic_mem* tic = music->tic; 2198 - static u8 Colors[] = 2198 + static u8 Colors[] = 2199 2199 { 2200 2200 tic_color_dark_green, tic_color_green, tic_color_light_green, tic_color_light_green 2201 2201 }; ··· 2211 2211 { 2212 2212 tic_mem* tic = music->tic; 2213 2213 2214 - static const struct Button {u8 note; u8 up; u8 down; u8 offset; u8 flip;} Buttons[] = 2214 + static const struct Button {u8 note; u8 up; u8 down; u8 offset; u8 flip;} Buttons[] = 2215 2215 { 2216 2216 {0, 39, 40, 0, tic_no_flip}, 2217 2217 {2, 39, 40, 3, tic_horz_flip}, ··· 2235 2235 for(s32 i = 0; i < COUNT_OF(Buttons); i++) 2236 2236 { 2237 2237 const struct Button* btn = &Buttons[i]; 2238 - tic_api_spr(tic, btn->note == music->piano.note[music->piano.col] ? btn->down : btn->up, 2238 + tic_api_spr(tic, btn->note == music->piano.note[music->piano.col] ? btn->down : btn->up, 2239 2239 x + btn->offset, y, 1, 1, (u8[]){tic_color_orange}, 1, 1, btn->flip, tic_no_rotate); 2240 2240 } 2241 2241 } ··· 2264 2264 { 2265 2265 music->scroll.active = true; 2266 2266 music->scroll.start = tic_api_mouse(tic).y + music->scroll.pos * TIC_FONT_HEIGHT; 2267 - } 2267 + } 2268 2268 } 2269 2269 else music->scroll.active = false; 2270 2270 } ··· 2293 2293 { 2294 2294 { 2295 2295 static const char Notes[] = "C D EF G A B"; 2296 - tic_api_print(tic, Notes, xpos, ypos, tic_color_dark_grey, true, 1, true); 2296 + tic_api_print(tic, Notes, xpos, ypos, tic_color_dark_grey, true, 1, true); 2297 2297 } 2298 2298 2299 2299 showTooltip(music->studio, "set note"); ··· 2407 2407 2408 2408 if(noteBeat(music, index) && row->note != NoteStop) 2409 2409 { 2410 - static u8 Colors[NOTES] = 2410 + static u8 Colors[NOTES] = 2411 2411 { 2412 - tic_color_grey, tic_color_grey, tic_color_light_grey, 2413 - tic_color_light_grey, tic_color_light_grey, tic_color_white, 2414 - tic_color_white, tic_color_light_grey, tic_color_light_grey, 2412 + tic_color_grey, tic_color_grey, tic_color_light_grey, 2413 + tic_color_light_grey, tic_color_light_grey, tic_color_white, 2414 + tic_color_white, tic_color_light_grey, tic_color_light_grey, 2415 2415 tic_color_light_grey, tic_color_grey, tic_color_grey 2416 2416 }; 2417 2417 ··· 2499 2499 } 2500 2500 else 2501 2501 for(s32 i = 0; i < OCTAVES; i++) 2502 - tic_api_rect(tic, x + i * OctaveWidth, y + r * OctaveHeight + (Header + OctaveHeight / 2 - 1), OctaveWidth - 1, 1, tic_color_dark_grey); 2502 + tic_api_rect(tic, x + i * OctaveWidth, y + r * OctaveHeight + (Header + OctaveHeight / 2 - 1), OctaveWidth - 1, 1, tic_color_dark_grey); 2503 2503 2504 2504 if(noteBeat(music, index)) 2505 2505 { 2506 - static u8 Colors[OCTAVES] = 2506 + static u8 Colors[OCTAVES] = 2507 2507 { 2508 2508 tic_color_grey, tic_color_grey, tic_color_light_grey, tic_color_white, 2509 2509 tic_color_white, tic_color_light_grey, tic_color_grey, tic_color_grey ··· 2517 2517 tic_api_rect(tic, x + row->octave * OctaveWidth, y + Header + r * OctaveHeight, OctaveWidth - 1, OctaveHeight - 1, tic_color_orange); 2518 2518 } 2519 2519 } 2520 - else 2520 + else 2521 2521 for(s32 r = 0; r < TRACKER_ROWS; r++) 2522 2522 for(s32 i = 0; i < OCTAVES; i++) 2523 2523 tic_api_rect(tic, x + i * OctaveWidth, y + r * OctaveHeight + (Header + OctaveHeight / 2 - 1), OctaveWidth - 1, 1, tic_color_dark_grey); ··· 2583 2583 tic_api_print(tic, sfx, rect.x + 1, rect.y + 1, tic_color_yellow, true, 1, false); 2584 2584 } 2585 2585 else 2586 - tic_api_print(tic, "--", 2587 - x + 1, y + Header + r * TIC_FONT_HEIGHT, 2586 + tic_api_print(tic, "--", 2587 + x + 1, y + Header + r * TIC_FONT_HEIGHT, 2588 2588 noteBeat(music, index) ? tic_color_light_grey : tic_color_grey, true, 1, false); 2589 - } 2589 + } 2590 2590 } 2591 2591 else 2592 2592 for(s32 r = 0; r < TRACKER_ROWS; r++) ··· 2628 2628 if(command != tic_music_cmd_empty) 2629 2629 { 2630 2630 #define MUSIC_CMD_HINT(_, letter, hint) "[" #letter "] " hint, 2631 - static const char* Hints[] = 2631 + static const char* Hints[] = 2632 2632 { 2633 2633 MUSIC_CMD_LIST(MUSIC_CMD_HINT) 2634 2634 }; ··· 2663 2663 s32 index = rowIndex(music, r); 2664 2664 const tic_track_row* row = &pattern->rows[index]; 2665 2665 2666 - tic_api_print(tic, MusicCommands + 1, 2667 - x + 1, y + Header + r * TIC_FONT_HEIGHT, 2666 + tic_api_print(tic, MusicCommands + 1, 2667 + x + 1, y + Header + r * TIC_FONT_HEIGHT, 2668 2668 noteBeat(music, index) ? tic_color_grey : tic_color_dark_grey, true, 1, false); 2669 2669 2670 2670 if(overRow == r && command > tic_music_cmd_empty) 2671 - tic_api_print(tic, (char[]){MusicCommands[command], '\0'}, 2672 - x + 1 + (command - 1) * TIC_FONT_WIDTH, y + Header + r * TIC_FONT_HEIGHT, 2671 + tic_api_print(tic, (char[]){MusicCommands[command], '\0'}, 2672 + x + 1 + (command - 1) * TIC_FONT_WIDTH, y + Header + r * TIC_FONT_HEIGHT, 2673 2673 noteBeat(music, index) ? tic_color_light_grey : tic_color_grey, true, 1, false); 2674 2674 2675 2675 if(row->command > tic_music_cmd_empty) 2676 - tic_api_print(tic, (char[]){MusicCommands[row->command], '\0'}, 2677 - x + 1 + (row->command - 1) * TIC_FONT_WIDTH, y + Header + r * TIC_FONT_HEIGHT, 2676 + tic_api_print(tic, (char[]){MusicCommands[row->command], '\0'}, 2677 + x + 1 + (row->command - 1) * TIC_FONT_WIDTH, y + Header + r * TIC_FONT_HEIGHT, 2678 2678 tic_color_light_blue, true, 1, false); 2679 - } 2679 + } 2680 2680 } 2681 2681 else 2682 2682 for(s32 r = 0; r < TRACKER_ROWS; r++) 2683 - tic_api_print(tic, MusicCommands + 1, 2684 - x + 1, y + Header + r * TIC_FONT_HEIGHT, 2683 + tic_api_print(tic, MusicCommands + 1, 2684 + x + 1, y + Header + r * TIC_FONT_HEIGHT, 2685 2685 tic_color_dark_grey, true, 1, false); 2686 2686 } 2687 2687 ··· 2710 2710 char val[sizeof "XY=000"]; 2711 2711 sprintf(val, "XY=%03i", (row->param1 << 4) | row->param2); 2712 2712 tic_api_print(tic, val, 213, 129, tic_color_yellow, false, 1, true); 2713 - } 2713 + } 2714 2714 } 2715 2715 2716 2716 bool left = checkMouseClick(music->studio, &rect, tic_mouse_left); ··· 2760 2760 tic_api_print(tic, xy, x + 1, y + Header + r * TIC_FONT_HEIGHT, tic_color_light_blue, true, 1, false); 2761 2761 } 2762 2762 else 2763 - tic_api_print(tic, "--", 2764 - x + 1, y + Header + r * TIC_FONT_HEIGHT, 2763 + tic_api_print(tic, "--", 2764 + x + 1, y + Header + r * TIC_FONT_HEIGHT, 2765 2765 noteBeat(music, index) ? tic_color_light_grey : tic_color_grey, true, 1, false); 2766 - } 2766 + } 2767 2767 } 2768 2768 else 2769 2769 for(s32 r = 0; r < TRACKER_ROWS; r++) ··· 2851 2851 rect.y = music->tracker.edit.y; 2852 2852 rect.h = 1; 2853 2853 } 2854 - 2854 + 2855 2855 for(s32 i = rect.y; i < rect.y + rect.h; i++) 2856 2856 { 2857 2857 s32 note = pattern->rows[i].note + pattern->rows[i].octave * NOTES - NoteStart; ··· 2950 2950 scrollNotes(music, input->mouse.scrolly > 0 ? 1 : -1); 2951 2951 } 2952 2952 else 2953 - { 2953 + { 2954 2954 enum{Scroll = NOTES_PER_BEAT}; 2955 2955 s32 delta = input->mouse.scrolly > 0 ? -Scroll : Scroll; 2956 2956 ··· 2967 2967 { 2968 2968 const tic_music_state* pos = getMusicPos(music); 2969 2969 2970 - if(pos->music.track == music->track && 2970 + if(pos->music.track == music->track && 2971 2971 music->tracker.edit.y >= 0 && 2972 2972 pos->music.row >= 0) 2973 2973 { ··· 3028 3028 .frame = 0, 3029 3029 .follow = true, 3030 3030 .sustain = false, 3031 - .scroll = 3031 + .scroll = 3032 3032 { 3033 3033 .pos = 0, 3034 3034 .start = 0, ··· 3044 3044 { 3045 3045 .edit = {0, 0}, 3046 3046 3047 - .select = 3047 + .select = 3048 3048 { 3049 3049 .start = {0, 0}, 3050 3050 .rect = {0, 0, 0, 0},
+1 -1
src/studio/editors/music.h
··· 92 92 u32 tickCounter; 93 93 94 94 struct History* history; 95 - 95 + 96 96 void(*tick)(Music*); 97 97 void(*event)(Music*, StudioEvent); 98 98 };
+41 -41
src/studio/editors/sfx.c
··· 28 28 #define SECOND_OCTAVE_KEYBOARD_INDEX 16 29 29 #define SECOND_OCTAVE_KEYBOARD_SHIFT 5 30 30 31 - enum 31 + enum 32 32 { 33 33 SFX_WAVE_PANEL, 34 34 SFX_VOLUME_PANEL, ··· 60 60 { 61 61 tic_mem* tic = sfx->tic; 62 62 63 - if(tic_api_key(tic, tic_key_ctrl) || 63 + if(tic_api_key(tic, tic_key_ctrl) || 64 64 tic_api_key(tic, tic_key_shift)) 65 65 { 66 66 if(sfx->holdValue < 0) ··· 81 81 { 82 82 tic_mem* tic = sfx->tic; 83 83 84 - enum 84 + enum 85 85 { 86 - Cols = SFX_TICKS, Rows = 16, 86 + Cols = SFX_TICKS, Rows = 16, 87 87 Gap = 1, LedWidth = 3 + Gap, LedHeight = 1 + Gap, 88 - Width = LedWidth * Cols + Gap, 88 + Width = LedWidth * Cols + Gap, 89 89 Height = LedHeight * Rows + Gap 90 90 }; 91 91 ··· 182 182 for(s32 r = 0; r < Rows; r++) 183 183 { 184 184 tic_api_rect(tic, x + loop->start * LedWidth + 2, y + Gap + r * LedHeight, 1, 1, tic_color_white); 185 - tic_api_rect(tic, x + (loop->start + loop->size-1) * LedWidth + 2, y + Gap + r * LedHeight, 1, 1, tic_color_white); 185 + tic_api_rect(tic, x + (loop->start + loop->size-1) * LedWidth + 2, y + Gap + r * LedHeight, 1, 1, tic_color_white); 186 186 } 187 187 } 188 188 ··· 298 298 tic_mem* tic = sfx->tic; 299 299 300 300 typedef struct {const char* label; s32 panel; tic_rect rect; const char* tip;} Item; 301 - static const Item Items[] = 301 + static const Item Items[] = 302 302 { 303 303 {"WAV", SFX_WAVE_PANEL, {TIC_ALTFONT_WIDTH * 3, 0, TIC_ALTFONT_WIDTH * 3, TIC_FONT_HEIGHT}, "wave data"}, 304 304 {"VOL", SFX_VOLUME_PANEL, {0, 0, TIC_ALTFONT_WIDTH * 3, TIC_FONT_HEIGHT}, "volume data"}, ··· 332 332 { 333 333 tic_mem* tic = sfx->tic; 334 334 335 - enum 335 + enum 336 336 { 337 337 Width = 147, Height = 33 338 338 }; ··· 544 544 545 545 s32 keyboardButton = -1; 546 546 547 - static const s32 Keycodes[] = 547 + static const s32 Keycodes[] = 548 548 { 549 549 tic_key_z, 550 550 tic_key_s, ··· 577 577 tic_key_y, 578 578 tic_key_7, 579 579 tic_key_u, 580 - 580 + 581 581 // extra keys 582 582 tic_key_i, 583 583 tic_key_9, ··· 595 595 else 596 596 { 597 597 u8 octaveShift = 0; 598 - for(int i = 0; i < COUNT_OF(Keycodes); i++) { 598 + for(int i = 0; i < COUNT_OF(Keycodes); i++) { 599 599 if(tic_api_key(tic, Keycodes[i])) { 600 - if (sfx->play.tick == 0 && !keyWasPressedOnce(tic, Keycodes[i])) 600 + if (sfx->play.tick == 0 && !keyWasPressedOnce(tic, Keycodes[i])) 601 601 continue; 602 602 603 - keyboardButton = (i > SECOND_OCTAVE_KEYBOARD_INDEX 604 - ? i - SECOND_OCTAVE_KEYBOARD_SHIFT 603 + keyboardButton = (i > SECOND_OCTAVE_KEYBOARD_INDEX 604 + ? i - SECOND_OCTAVE_KEYBOARD_SHIFT 605 605 : i) % NOTES; 606 - 606 + 607 607 octaveShift = (i - keyboardButton) / NOTES; 608 608 } 609 609 } 610 610 611 - if (effect->temp != octaveShift) 611 + if (effect->temp != octaveShift) 612 612 sfx->play.tick = 0; 613 613 614 614 effect->temp = octaveShift; ··· 618 618 { 619 619 if (keyboardButton != sfx->play.note) 620 620 sfx->play.tick = 0; 621 - 621 + 622 622 effect->note = keyboardButton; 623 623 sfx->play.active = true; 624 624 } ··· 626 626 if(tic_api_key(tic, tic_key_space)) 627 627 sfx->play.active = true; 628 628 629 - if(keyWasPressedOnce(tic, tic_key_z) && shift) 629 + if(keyWasPressedOnce(tic, tic_key_z) && shift) 630 630 effect->octave--; 631 - else if(keyWasPressedOnce(tic, tic_key_x) && shift) 631 + else if(keyWasPressedOnce(tic, tic_key_x) && shift) 632 632 effect->octave++; 633 633 } 634 634 ··· 693 693 694 694 static void drawWavesBar(Sfx* sfx, s32 x, s32 y) 695 695 { 696 - static struct Button 696 + static struct Button 697 697 { 698 698 u8 icon; 699 699 const char* tip; 700 700 void(*handler)(Sfx*); 701 - } Buttons[] = 701 + } Buttons[] = 702 702 { 703 703 { 704 704 tic_icon_cut, ··· 752 752 if(over) 753 753 drawBitIcon(sfx->studio, it->icon, rect.x, rect.y + 1, tic_color_black); 754 754 755 - drawBitIcon(sfx->studio, it->icon, rect.x, rect.y + push, 755 + drawBitIcon(sfx->studio, it->icon, rect.x, rect.y + push, 756 756 over ? tic_color_white : tic_color_dark_grey); 757 757 758 758 y += Size; ··· 805 805 for(s32 i = 0; i < WAVE_VALUES/Scale; i++) 806 806 { 807 807 s32 value = tic_tool_peek4(wave->data, i*Scale)/Scale; 808 - tic_api_pix(tic, rect.x + i+1, rect.y + Height - value - 2, 808 + tic_api_pix(tic, rect.x + i+1, rect.y + Height - value - 2, 809 809 active ? tic_color_red : sel ? tic_color_dark_green : hover ? tic_color_light_grey : tic_color_white, false); 810 810 } 811 811 ··· 825 825 826 826 enum {Width = 73, Height = 83, Round = 2}; 827 827 828 - typedef struct {s32 x; s32 y; s32 x1; s32 y1; tic_color color;} Edge; 829 - static const Edge Edges[] = 828 + typedef struct {s32 x; s32 y; s32 x1; s32 y1; tic_color color;} Edge; 829 + static const Edge Edges[] = 830 830 { 831 831 {Width, Round, Width, Height - Round, tic_color_dark_grey}, 832 832 {Round, Height, Width - Round, Height, tic_color_dark_grey}, ··· 871 871 SHOW_TOOLTIP(sfx->studio, "[x=%02i y=%02i]", cx, cy); 872 872 873 873 enum {Border = 1}; 874 - tic_api_rectb(tic, rect.x + cx*Scale - Border, 874 + tic_api_rectb(tic, rect.x + cx*Scale - Border, 875 875 rect.y + (MaxValue - cy) * Scale - Border, Scale + Border*2, Scale + Border*2, tic_color_dark_green); 876 876 877 877 if(checkMouseDown(sfx->studio, &rect, tic_mouse_left)) ··· 885 885 } 886 886 } 887 887 else unhold(sfx); 888 - } 888 + } 889 889 890 890 for(s32 i = 0; i < WAVE_VALUES; i++) 891 891 { ··· 909 909 { 910 910 tic_mem* tic = sfx->tic; 911 911 912 - enum 912 + enum 913 913 { 914 914 Gap = 1, WhiteShadow = 1, 915 915 WhiteWidth = 3, WhiteHeight = 8, WhiteCount = 7, WhiteWidthGap = WhiteWidth + Gap, 916 - BlackWidth = 3, BlackHeight = 4, BlackCount = 6, 916 + BlackWidth = 3, BlackHeight = 4, BlackCount = 6, 917 917 BlackOffset = WhiteWidth - (BlackWidth - Gap) / 2, 918 918 Width = WhiteCount * WhiteWidthGap - Gap, 919 919 Height = WhiteHeight ··· 922 922 tic_rect rect = {x, y, Width, Height}; 923 923 924 924 typedef struct{s32 note; tic_rect rect; bool white;} PianoBtn; 925 - static const PianoBtn Buttons[] = 925 + static const PianoBtn Buttons[] = 926 926 { 927 927 {0, WhiteWidthGap * 0, 0, WhiteWidth, WhiteHeight, true}, 928 928 {2, WhiteWidthGap * 1, 0, WhiteWidth, WhiteHeight, true}, ··· 987 987 { 988 988 const PianoBtn* btn = Buttons + i; 989 989 const tic_rect* rect = &btn->rect; 990 - tic_api_rect(tic, x + rect->x, y + rect->y, rect->w, rect->h, 991 - active && effect->note == btn->note ? tic_color_red : 992 - btn->white 993 - ? hover == btn->note ? tic_color_light_grey : tic_color_white 990 + tic_api_rect(tic, x + rect->x, y + rect->y, rect->w, rect->h, 991 + active && effect->note == btn->note ? tic_color_red : 992 + btn->white 993 + ? hover == btn->note ? tic_color_light_grey : tic_color_white 994 994 : hover == btn->note ? tic_color_dark_grey : tic_color_black); 995 995 996 996 if(btn->white) ··· 1019 1019 { 1020 1020 tic_mem* tic = sfx->tic; 1021 1021 1022 - enum 1022 + enum 1023 1023 { 1024 - Count = 8, Gap = 1, ColWidth = 1, ColWidthGap = ColWidth + Gap, 1024 + Count = 8, Gap = 1, ColWidth = 1, ColWidthGap = ColWidth + Gap, 1025 1025 Width = Count * ColWidthGap - Gap, Height = 5, 1026 1026 MaxSpeed = (1 << SFX_SPEED_BITS) / 2 1027 1027 }; ··· 1058 1058 1059 1059 enum 1060 1060 { 1061 - Size = 3, Gap = 1, SizeGap = Size + Gap, 1061 + Size = 3, Gap = 1, SizeGap = Size + Gap, 1062 1062 GroupGap = 2, Groups = 4, Cols = 4, Rows = SFX_COUNT / (Cols * Groups), 1063 1063 GroupWidth = Cols * SizeGap - Gap, 1064 1064 Width = (GroupWidth + GroupGap) * Groups - GroupGap, Height = Rows * SizeGap - Gap ··· 1096 1096 static const u8 EmptyEffect[sizeof(tic_sample)] = {0}; 1097 1097 bool empty = memcmp(sfx->src->samples.data + i, EmptyEffect, sizeof EmptyEffect) == 0; 1098 1098 1099 - tic_api_rect(tic, x + c * SizeGap + g * (GroupWidth + GroupGap), y + r * SizeGap, Size, Size, 1099 + tic_api_rect(tic, x + c * SizeGap + g * (GroupWidth + GroupGap), y + r * SizeGap, Size, Size, 1100 1100 sfx->index == i ? tic_color_light_green : hover == i ? tic_color_grey : empty ? tic_color_dark_grey : tic_color_light_grey); 1101 1101 } 1102 1102 } ··· 1145 1145 1146 1146 if(sfx->play.active) 1147 1147 sfx->play.tick++; 1148 - else 1148 + else 1149 1149 sfx->play.tick = 0; 1150 1150 } 1151 1151 ··· 1166 1166 { 1167 1167 if(sfx->history) history_delete(sfx->history); 1168 1168 if(sfx->waveHistory) history_delete(sfx->waveHistory); 1169 - 1169 + 1170 1170 *sfx = (Sfx) 1171 1171 { 1172 1172 .studio = studio, ··· 1177 1177 .volwave = SFX_VOLUME_PANEL, 1178 1178 .hoverWave = -1, 1179 1179 .holdValue = -1, 1180 - .play = 1180 + .play = 1181 1181 { 1182 1182 .note = -1, 1183 1183 .active = false,
+1 -1
src/studio/editors/sfx.h
··· 44 44 s32 note; 45 45 u32 tick; 46 46 } play; 47 - 47 + 48 48 struct History* history; 49 49 struct History* waveHistory; 50 50
+56 -56
src/studio/editors/sprite.c
··· 506 506 { 507 507 switch(sprite->mode) 508 508 { 509 - case SPRITE_DRAW_MODE: 509 + case SPRITE_DRAW_MODE: 510 510 processDrawCanvasMouse(sprite, x, y, rect.x, rect.y); 511 511 drawBrushSlider(sprite, x - 15, y + 20); 512 512 break; 513 513 case SPRITE_PICK_MODE: processPickerCanvasMouse(sprite, x, y, rect.x, rect.y); break; 514 514 case SPRITE_SELECT_MODE: processSelectCanvasMouse(sprite, x, y); break; 515 515 case SPRITE_FILL_MODE: processFillCanvasMouse(sprite, x, y, rect.x, rect.y); break; 516 - } 516 + } 517 517 } 518 518 519 519 if(hasCanvasSelection(sprite)) 520 - drawSelection(sprite, x + sprite->select.rect.x * Size - 1, y + sprite->select.rect.y * Size - 1, 520 + drawSelection(sprite, x + sprite->select.rect.x * Size - 1, y + sprite->select.rect.y * Size - 1, 521 521 sprite->select.rect.w * Size + 2, sprite->select.rect.h * Size + 2); 522 522 else 523 523 { ··· 589 589 static void rotateSelectRect(Sprite* sprite) 590 590 { 591 591 tic_rect rect = sprite->select.rect; 592 - 592 + 593 593 s32 selection_center_x = rect.x + rect.w/2; 594 594 s32 selection_center_y = rect.y + rect.h/2; 595 - 595 + 596 596 // Rotate 597 597 sprite->select.rect.w = rect.h; 598 598 sprite->select.rect.h = rect.w; 599 - 599 + 600 600 // Make the new center be at the position of the previous center 601 601 sprite->select.rect.x -= (sprite->select.rect.x + sprite->select.rect.w/2) - selection_center_x; 602 602 sprite->select.rect.y -= (sprite->select.rect.y + sprite->select.rect.h/2) - selection_center_y; 603 - 603 + 604 604 // Check if we are not out of boundaries 605 605 if (sprite->select.rect.x < 0) sprite->select.rect.x = 0; 606 606 if (sprite->select.rect.y < 0) sprite->select.rect.y = 0; 607 - 607 + 608 608 if (sprite->select.rect.x + sprite->select.rect.w >= sprite->size) 609 609 { 610 610 sprite->select.rect.x -= sprite->select.rect.x + sprite->select.rect.w - sprite->size; 611 611 } 612 - 612 + 613 613 if (sprite->select.rect.y + sprite->select.rect.h >= sprite->size) 614 614 { 615 615 sprite->select.rect.y -= sprite->select.rect.y + sprite->select.rect.h - sprite->size; ··· 633 633 diff = rect.w * (x + 1) -y; 634 634 buffer[i++] = sprite->select.front[Size - diff]; 635 635 } 636 - 636 + 637 637 for (s32 i = 0; i<Size; i++) 638 638 sprite->select.front[i] = buffer[i]; 639 - 639 + 640 640 rotateSelectRect(sprite); 641 641 pasteSelection(sprite); 642 642 history_add(sprite->history); ··· 649 649 static void deleteCanvas(Sprite* sprite) 650 650 { 651 651 tic_rect* rect = &sprite->select.rect; 652 - 652 + 653 653 s32 left = getIndexPosX(sprite) + rect->x; 654 654 s32 top = getIndexPosY(sprite) + rect->y; 655 655 s32 right = left + rect->w; ··· 660 660 tic_tilesheet_setpix(&sprite->sheet, pixel_x, pixel_y, sprite->color2); 661 661 662 662 clearCanvasSelection(sprite); 663 - 663 + 664 664 history_add(sprite->history); 665 665 } 666 666 667 667 static void flipCanvasHorz(Sprite* sprite) 668 668 { 669 669 tic_rect* rect = &sprite->select.rect; 670 - 670 + 671 671 s32 sprite_x = getIndexPosX(sprite); 672 672 s32 sprite_y = getIndexPosY(sprite); 673 - 673 + 674 674 s32 right = sprite_x + rect->x + rect->w/2; 675 675 s32 bottom = sprite_y + rect->y + rect->h; 676 676 ··· 689 689 static void flipCanvasVert(Sprite* sprite) 690 690 { 691 691 tic_rect* rect = &sprite->select.rect; 692 - 692 + 693 693 s32 sprite_x = getIndexPosX(sprite); 694 694 s32 sprite_y = getIndexPosY(sprite); 695 - 695 + 696 696 s32 right = sprite_x + rect->x + rect->w; 697 697 s32 bottom = sprite_y + rect->y + rect->h/2; 698 698 ··· 749 749 u8 mask = flags[*i++]; 750 750 or |= mask; 751 751 and &= mask; 752 - } 752 + } 753 753 } 754 754 755 755 for(s32 i = 0; i < BITS_IN_BYTE; i++) ··· 773 773 while(*i >= 0) 774 774 flags[*i++] &= ~mask; 775 775 else 776 - while(*i >= 0) 776 + while(*i >= 0) 777 777 flags[*i++] |= mask; 778 778 } 779 779 } ··· 786 786 tic_api_pix(tic, rect.x + 2, rect.y + 2, flagColor, false); 787 787 else if(over) 788 788 tic_api_rect(tic, rect.x + 1, rect.y + 1, Size - 2, Size - 2, flagColor); 789 - 789 + 790 790 if(and & mask) 791 791 { 792 792 tic_api_rect(tic, rect.x + 1, rect.y + 1, Size - 2, Size - 2, flagColor); ··· 830 830 831 831 if(!sprite->flags.edit) 832 832 tic_api_print(tic, buf, rect.x + 1, rect.y + 2, tic_color_black, false, 1, true); 833 - 833 + 834 834 tic_api_print(tic, buf, rect.x + 1, rect.y + 1, tic_color_white, false, 1, true); 835 835 } 836 836 } ··· 903 903 904 904 static const u8 Icons[] = {tic_icon_bigup, tic_icon_bigdown, tic_icon_bigleft, tic_icon_bigright}; 905 905 906 - static const tic_rect Rects[] = 906 + static const tic_rect Rects[] = 907 907 { 908 908 {x + (CANVAS_SIZE - TIC_SPRITESIZE)/2, y - TIC_SPRITESIZE, TIC_SPRITESIZE, TIC_SPRITESIZE/2}, 909 909 {x + (CANVAS_SIZE - TIC_SPRITESIZE)/2, y + CANVAS_SIZE + TIC_SPRITESIZE/2, TIC_SPRITESIZE, TIC_SPRITESIZE/2}, ··· 1029 1029 { 1030 1030 { 1031 1031 enum{Size = 5}; 1032 - 1032 + 1033 1033 tic_rect rect = {x, y, Size, Size}; 1034 1034 1035 1035 bool over = false; ··· 1062 1062 1063 1063 { 1064 1064 enum{Size = 5}; 1065 - 1065 + 1066 1066 tic_rect rect = {x, y + 8, Size, Size}; 1067 1067 bool over = false; 1068 1068 bool down = false; ··· 1101 1101 1102 1102 enum 1103 1103 { 1104 - Cols = BITS_IN_BYTE / TIC_PALETTE_BPP, 1105 - Rows = sizeof(tic_rgb), 1106 - Width = TIC_FONT_WIDTH + 1, 1104 + Cols = BITS_IN_BYTE / TIC_PALETTE_BPP, 1105 + Rows = sizeof(tic_rgb), 1106 + Width = TIC_FONT_WIDTH + 1, 1107 1107 Height = TIC_FONT_HEIGHT + 1 1108 1108 }; 1109 1109 ··· 1133 1133 if(hasFocus) 1134 1134 { 1135 1135 drawPanelBorder(sprite->tic, rect.x, rect.y, rect.w, rect.h); 1136 - tic_api_rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, tic_color_black); 1136 + tic_api_rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, tic_color_black); 1137 1137 } 1138 1138 1139 1139 for(s32 i = 0; i < Rows; i++) 1140 1140 { 1141 1141 char buf[sizeof "FF"]; 1142 1142 sprintf(buf, "%02X", data[i]); 1143 - tic_api_print(tic, buf, rect.x + 1, rect.y + i * TIC_FONT_HEIGHT + 1, 1143 + tic_api_print(tic, buf, rect.x + 1, rect.y + i * TIC_FONT_HEIGHT + 1, 1144 1144 hasFocus ? tic_color_grey : tic_color_light_grey, true, 1, false); 1145 1145 } 1146 1146 ··· 1332 1332 else 1333 1333 { 1334 1334 drawBitIcon(sprite->studio, tic_icon_rgb, rect.x, rect.y+1, tic_color_black); 1335 - drawBitIcon(sprite->studio, tic_icon_rgb, rect.x, rect.y, (over ? tic_color_light_grey : tic_color_white)); 1335 + drawBitIcon(sprite->studio, tic_icon_rgb, rect.x, rect.y, (over ? tic_color_light_grey : tic_color_white)); 1336 1336 } 1337 1337 } 1338 1338 } ··· 1350 1350 static void selectSprite(Sprite* sprite, s32 x, s32 y) 1351 1351 { 1352 1352 { 1353 - s32 size = TIC_SPRITESHEET_SIZE - sprite->size; 1353 + s32 size = TIC_SPRITESHEET_SIZE - sprite->size; 1354 1354 if(x < 0) x = 0; 1355 1355 if(y < 0) y = 0; 1356 1356 if(x > size) x = size; ··· 1380 1380 1381 1381 for(s32 i = 1; i < rect.h; i += 4) 1382 1382 { 1383 - if (sprite->blit.page > 0) 1383 + if (sprite->blit.page > 0) 1384 1384 { 1385 1385 tic_api_pix(tic, rect.x-1, rect.y + i, tic_color_black, false); 1386 1386 tic_api_pix(tic, rect.x-1, rect.y + i + 1, tic_color_black, false); 1387 1387 } 1388 1388 1389 - if (sprite->blit.page < sprite->blit.pages - 1) 1389 + if (sprite->blit.page < sprite->blit.pages - 1) 1390 1390 { 1391 1391 tic_api_pix(tic, rect.x+rect.w, rect.y + i, tic_color_black, false); 1392 1392 tic_api_pix(tic, rect.x+rect.w, rect.y + i + 1, tic_color_black, false); ··· 1418 1418 tic_blit blit = sprite->blit; 1419 1419 SCOPE(tic->ram->vram.blit.segment = TIC_DEFAULT_BLIT_MODE) 1420 1420 { 1421 - tic_point start = 1421 + tic_point start = 1422 1422 { 1423 1423 x - blit.page * TIC_SPRITESHEET_SIZE + sprite->anim.pos.page, 1424 1424 y - blit.bank * TIC_SPRITESHEET_SIZE + sprite->anim.pos.bank ··· 1537 1537 { 1538 1538 bool pushed = false; 1539 1539 bool over = false; 1540 - 1540 + 1541 1541 tic_rect rect = {x + i * Gap, y, TIC_SPRITESIZE, TIC_SPRITESIZE}; 1542 1542 1543 1543 if(checkMousePos(sprite->studio, &rect)) ··· 1551 1551 if(checkMouseDown(sprite->studio, &rect, tic_mouse_left)) pushed = true; 1552 1552 1553 1553 if(checkMouseClick(sprite->studio, &rect, tic_mouse_left)) 1554 - { 1554 + { 1555 1555 if(hasCanvasSelection(sprite)) 1556 1556 { 1557 1557 CanvasToolsFunc[i](sprite); ··· 1597 1597 showTooltip(sprite->studio, Tooltips[i]); 1598 1598 1599 1599 if(checkMouseClick(sprite->studio, &rect, tic_mouse_left)) 1600 - { 1600 + { 1601 1601 sprite->mode = i; 1602 1602 1603 1603 clearCanvasSelection(sprite); ··· 1723 1723 1724 1724 static void rightSprite(Sprite* sprite) 1725 1725 { 1726 - if ((sprite->x + sprite->size/TIC_SPRITESIZE) < TIC_SPRITESHEET_COLS) sprite->x++; 1726 + if ((sprite->x + sprite->size/TIC_SPRITESIZE) < TIC_SPRITESHEET_COLS) sprite->x++; 1727 1727 updateIndex(sprite); 1728 1728 } 1729 1729 ··· 1797 1797 1798 1798 if(checkMouseClick(sprite->studio, &rect, tic_mouse_left)) 1799 1799 { 1800 - if (!current) 1800 + if (!current) 1801 1801 { 1802 1802 switchBanks(sprite); 1803 1803 } ··· 1905 1905 bool ctrl = tic_api_key(tic, tic_key_ctrl); 1906 1906 1907 1907 if(ctrl) 1908 - { 1908 + { 1909 1909 if(keyWasPressed(sprite->studio, tic_key_z)) undo(sprite); 1910 1910 else if(keyWasPressed(sprite->studio, tic_key_y)) redo(sprite); 1911 1911 ··· 1913 1913 else if(keyWasPressed(sprite->studio, tic_key_right)) rightViewport(sprite); 1914 1914 1915 1915 else if(keyWasPressed(sprite->studio, tic_key_tab)) 1916 - switchBitMode(sprite, sprite->blit.mode == tic_bpp_4 1917 - ? tic_bpp_2 1918 - : sprite->blit.mode == tic_bpp_2 1919 - ? tic_bpp_1 1916 + switchBitMode(sprite, sprite->blit.mode == tic_bpp_4 1917 + ? tic_bpp_2 1918 + : sprite->blit.mode == tic_bpp_2 1919 + ? tic_bpp_1 1920 1920 : tic_bpp_4); 1921 1921 } 1922 1922 else ··· 1938 1938 else if(keyWasPressed(sprite->studio, tic_key_5)) flipCanvasHorz(sprite); 1939 1939 else if(keyWasPressed(sprite->studio, tic_key_6)) flipCanvasVert(sprite); 1940 1940 else if(keyWasPressed(sprite->studio, tic_key_7)) rotateCanvas(sprite); 1941 - else if(keyWasPressed(sprite->studio, tic_key_8)) deleteCanvas(sprite); 1941 + else if(keyWasPressed(sprite->studio, tic_key_8)) deleteCanvas(sprite); 1942 1942 } 1943 1943 } 1944 1944 else ··· 1969 1969 else if(keyWasPressed(sprite->studio, tic_key_equals)) updateBrushSize(sprite, +1); 1970 1970 else if(keyWasPressed(sprite->studio, tic_key_leftbracket)) updateColorIndex(sprite, -1); 1971 1971 else if(keyWasPressed(sprite->studio, tic_key_rightbracket)) updateColorIndex(sprite, +1); 1972 - } 1972 + } 1973 1973 } 1974 1974 } 1975 1975 } ··· 2054 2054 static void scanline(tic_mem* tic, s32 row, void* data) 2055 2055 { 2056 2056 Sprite* sprite = (Sprite*)data; 2057 - 2057 + 2058 2058 if(row == 0) 2059 2059 memcpy(&tic->ram->vram.palette, getBankPalette(sprite->studio, sprite->palette.vbank1), sizeof(tic_palette)); 2060 2060 } ··· 2103 2103 s32 size = sprite->size; 2104 2104 s32 delta = input->mouse.scrolly; 2105 2105 2106 - if(delta > 0) 2106 + if(delta > 0) 2107 2107 { 2108 2108 if(size < (TIC_SPRITESIZE * TIC_SPRITESIZE)) size <<= 1; 2109 2109 } 2110 2110 else if(size > TIC_SPRITESIZE) size >>= 1; 2111 2111 2112 - updateSpriteSize(sprite, size); 2112 + updateSpriteSize(sprite, size); 2113 2113 } 2114 2114 } 2115 2115 ··· 2123 2123 { 2124 2124 tic_api_cls(tic, tic->ram->vram.vars.clear = tic_color_cyan); 2125 2125 2126 - static const tic_rect bg[] = 2126 + static const tic_rect bg[] = 2127 2127 { 2128 2128 {0, ToolbarH, SheetX, CanvasY-ToolbarH}, 2129 2129 {0, CanvasY, CanvasX, CanvasH}, ··· 2155 2155 2156 2156 drawBankTabs(sprite, SheetX, 8); 2157 2157 2158 - sprite->palette.edit 2159 - ? drawRGBSliders(sprite, 24, 91) 2158 + sprite->palette.edit 2159 + ? drawRGBSliders(sprite, 24, 91) 2160 2160 : drawTools(sprite, 12, 96); 2161 2161 2162 2162 drawPaletteVBank1(sprite, 24, 112); 2163 2163 drawSheetVBank1(sprite, TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, 7); 2164 2164 drawAdvancedButton(sprite, 4, 11); 2165 - 2165 + 2166 2166 drawSpriteToolbar(sprite); 2167 2167 drawToolbar(sprite->studio, tic, false); 2168 2168 } ··· 2217 2217 .color = 2, 2218 2218 .color2 = 0, 2219 2219 .size = TIC_SPRITESIZE, 2220 - .palette = 2220 + .palette = 2221 2221 { 2222 2222 .edit = false, 2223 2223 .focus = -1, 2224 2224 }, 2225 2225 .brushSize = 1, 2226 - .select = 2226 + .select = 2227 2227 { 2228 2228 .rect = {0,0,0,0}, 2229 2229 .start = {0,0}, ··· 2248 2248 }), 2249 2249 }, 2250 2250 .event = onStudioEvent, 2251 - .scanline = scanline, 2251 + .scanline = scanline, 2252 2252 }; 2253 2253 2254 2254 sprite->anim.movie = resetMovie(&sprite->anim.idle);
+1 -1
src/studio/editors/sprite.h
··· 37 37 38 38 u32 tickCounter; 39 39 40 - struct 40 + struct 41 41 { 42 42 bool start; 43 43 tic_point last;
+1 -1
src/studio/editors/world.c
··· 82 82 tic_mem* tic = world->tic; 83 83 84 84 // process scroll 85 - if(tic->ram->input.mouse.scrolly > 0) 85 + if(tic->ram->input.mouse.scrolly > 0) 86 86 { 87 87 setStudioMode(world->studio, TIC_MAP_MODE); 88 88 return;
+12 -12
src/studio/fs.c
··· 76 76 { 77 77 EM_ASM({Module.syncFSRequests++;}); 78 78 } 79 - #endif 79 + #endif 80 80 81 81 const char* tic_fs_pathroot(tic_fs* fs, const char* name) 82 82 { ··· 104 104 strncpy(path, name + 1, sizeof path); 105 105 else if(strlen(fs->work)) 106 106 snprintf(path, sizeof path, "%s/%s", fs->work, name); 107 - else 107 + else 108 108 strncpy(path, name, sizeof path); 109 109 110 110 return tic_fs_pathroot(fs, path); ··· 140 140 141 141 typedef wchar_t FsString; 142 142 143 - #define __S(x) L ## x 143 + #define __S(x) L ## x 144 144 #define _S(x) __S(x) 145 145 146 146 static const FsString* utf8ToString(const char* str) ··· 444 444 445 445 #if defined(__EMSCRIPTEN__) 446 446 syncfs(); 447 - #endif 447 + #endif 448 448 449 449 return result; 450 450 #endif ··· 465 465 466 466 #if defined(__EMSCRIPTEN__) 467 467 syncfs(); 468 - #endif 468 + #endif 469 469 470 470 return result; 471 471 #endif ··· 593 593 } 594 594 595 595 u32 written=0; 596 - 596 + 597 597 res = f_write(&File, buffer, size, &written); 598 - 598 + 599 599 f_close(&File); 600 600 if (res != FR_OK) 601 601 { 602 602 return false; 603 603 } 604 604 if(written!=size) 605 - { 605 + { 606 606 dbg("Write size diff %d %d", size, written); 607 607 return false; 608 608 } ··· 810 810 dbg("tic_fs_load x %s\n", name); 811 811 dbg("fs.dir %s\n", fs->dir); 812 812 dbg("fs.work %s\n", fs->work); 813 - 813 + 814 814 if(isPublic(fs)) 815 815 { 816 816 dbg("Public ??\n"); ··· 827 827 FRESULT res = f_stat(fp, &fi); 828 828 dbg("fstat done %d \n", res); 829 829 830 - if(res!=FR_OK) 830 + if(res!=FR_OK) 831 831 { 832 832 dbg("NO F_STAT %d\n", res); 833 833 return NULL; ··· 849 849 dbg("F_READ %d %ld\n", res, read); 850 850 851 851 f_close(&file); 852 - if(read!=fi.fsize) 852 + if(read!=fi.fsize) 853 853 { 854 854 dbg("NO F_READ %d \n", res); 855 855 return NULL; ··· 880 880 fclose(file); 881 881 } 882 882 883 - return ptr; 883 + return ptr; 884 884 885 885 #endif 886 886 }
+14 -14
src/studio/net.c
··· 44 44 emscripten_fetch_attr_t attr; 45 45 }; 46 46 47 - static void downloadSucceeded(emscripten_fetch_t *fetch) 47 + static void downloadSucceeded(emscripten_fetch_t *fetch) 48 48 { 49 49 FetchData* data = (FetchData*)fetch->userData; 50 50 51 - net_get_data getData = 51 + net_get_data getData = 52 52 { 53 53 .type = net_get_done, 54 - .done = 54 + .done = 55 55 { 56 56 .size = fetch->numBytes, 57 57 .data = (u8*)fetch->data, ··· 68 68 emscripten_fetch_close(fetch); 69 69 } 70 70 71 - static void downloadFailed(emscripten_fetch_t *fetch) 71 + static void downloadFailed(emscripten_fetch_t *fetch) 72 72 { 73 73 FetchData* data = (FetchData*)fetch->userData; 74 74 75 - net_get_data getData = 75 + net_get_data getData = 76 76 { 77 77 .type = net_get_error, 78 - .error = 78 + .error = 79 79 { 80 80 .code = fetch->status, 81 81 }, ··· 90 90 emscripten_fetch_close(fetch); 91 91 } 92 92 93 - static void downloadProgress(emscripten_fetch_t *fetch) 93 + static void downloadProgress(emscripten_fetch_t *fetch) 94 94 { 95 95 FetchData* data = (FetchData*)fetch->userData; 96 96 97 - net_get_data getData = 97 + net_get_data getData = 98 98 { 99 99 .type = net_get_progress, 100 - .progress = 100 + .progress = 101 101 { 102 102 .size = fetch->dataOffset + fetch->numBytes, 103 103 .total = fetch->totalBytes, ··· 320 320 free(ctx); 321 321 } 322 322 323 - static void n3ds_net_apply_url(net_ctx *ctx, const char *url) 323 + static void n3ds_net_apply_url(net_ctx *ctx, const char *url) 324 324 { 325 325 snprintf(ctx->url, URL_SIZE, "http://%s%s", ctx->net->host, url); 326 326 } ··· 345 345 346 346 void tic_net_get(tic_net* net, const char* url, net_get_callback callback, void* calldata) 347 347 { 348 - net_ctx ctx = 348 + net_ctx ctx = 349 349 { 350 350 .net = net, 351 351 .callback = callback, ··· 438 438 net->requests[net->count - 1] = get; 439 439 } 440 440 441 - void tic_net_close(tic_net* net) 441 + void tic_net_close(tic_net* net) 442 442 { 443 443 for(s32 i = 0; i < net->count; i++) 444 444 { ··· 448 448 { 449 449 naettClose(it->res); 450 450 naettFree(it->req); 451 - free(it); 451 + free(it); 452 452 } 453 453 } 454 454 ··· 471 471 { 472 472 s32 status = naettGetStatus(it->res); 473 473 474 - net_get_data getData = 474 + net_get_data getData = 475 475 { 476 476 .calldata = it->calldata, 477 477 .url = it->url,
+6 -6
src/studio/project.c
··· 29 29 #include <ctype.h> 30 30 #include <stddef.h> 31 31 32 - static const struct BinarySection{const char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySections[] = 32 + static const struct BinarySection{const char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySections[] = 33 33 { 34 34 {"TILES", TIC_BANK_SPRITES, offsetof(tic_bank, tiles), sizeof(tic_tile), true}, 35 35 {"SPRITES", TIC_BANK_SPRITES, offsetof(tic_bank, sprites), sizeof(tic_tile), true}, ··· 73 73 74 74 static char* saveBinaryBuffer(char* ptr, const char* comment, const void* data, s32 size, s32 row, bool flip) 75 75 { 76 - if(bufferEmpty(data, size)) 76 + if(bufferEmpty(data, size)) 77 77 return ptr; 78 78 79 79 sprintf(ptr, "%s %03i:", comment, row); ··· 90 90 91 91 static char* saveBinarySection(char* ptr, const char* comment, const char* tag, s32 count, const void* data, s32 size, bool flip) 92 92 { 93 - if(bufferEmpty(data, size * count)) 93 + if(bufferEmpty(data, size * count)) 94 94 return ptr; 95 95 96 96 sprintf(ptr, "%s <%s>\n", comment, tag); ··· 128 128 { 129 129 makeTag(section->tag, tag, b); 130 130 131 - ptr = saveBinarySection(ptr, comment, tag, section->count, 131 + ptr = saveBinarySection(ptr, comment, tag, section->count, 132 132 (u8*)&cart->banks[b] + section->offset, section->size, section->flip); 133 133 } 134 134 ··· 199 199 memcpy(lineStr, ptr + strlen(comment) + 1, sizeof lineStr - 1); 200 200 201 201 s32 index = atoi(lineStr); 202 - 202 + 203 203 if(index < count) 204 204 { 205 205 ptr += strlen(comment) + sizeof(" 999:") - 1; ··· 209 209 ptr = getLineEnd(ptr); 210 210 } 211 211 else break; 212 - } 212 + } 213 213 } 214 214 else 215 215 {
+12 -12
src/studio/screens/console.c
··· 126 126 macro(vbank) \ 127 127 macro(id) \ 128 128 ALONE_KEY(macro) 129 - 129 + 130 130 static const char* WelcomeText = 131 131 "TIC-80 is a fantasy computer for making, playing and sharing tiny games.\n\n" 132 132 "It has built-in tools for development: code, sprites, maps, sound editors and the command line, " ··· 1232 1232 { 1233 1233 loadDemo(console, ln); 1234 1234 done = true; 1235 - } 1235 + } 1236 1236 } 1237 1237 1238 1238 if(!done) ··· 1834 1834 case 1: 1835 1835 bpp_scale = 4; 1836 1836 break; 1837 - case 2: 1837 + case 2: 1838 1838 bpp_scale = 2; 1839 1839 break; 1840 1840 default: 1841 1841 break; 1842 1842 } 1843 1843 u32 color1, color2, color3, color4, color; 1844 - 1844 + 1845 1845 for(s32 j = 0, y = params.y, h = y + (params.h ? params.h : img.height); y < h; ++y, ++j) 1846 1846 for(s32 i = 0, x = params.x, w = x + ((params.w ? params.w : img.width) / bpp_scale); x < w; ++x, i += bpp_scale) 1847 1847 if(x >= 0 && x < TIC_SPRITESHEET_SIZE && y >= 0 && y < TIC_SPRITESHEET_SIZE) ··· 3711 3711 free(rowReplaced); 3712 3712 #undef OFFSET 3713 3713 } 3714 - 3714 + 3715 3715 printFront(console, "\nCode Editor:\n"); 3716 3716 FOR(const struct HotkeysRowCodeEditor*, row, HotkeysTextCodeEditor) 3717 3717 { ··· 3722 3722 free(rowReplaced); 3723 3723 #undef OFFSET 3724 3724 } 3725 - 3725 + 3726 3726 printFront(console, "\nSprite Editor:\n"); 3727 3727 FOR(const struct HotkeysRowSpriteEditor*, row, HotkeysTextSpriteEditor) 3728 3728 { ··· 3733 3733 free(rowReplaced); 3734 3734 #undef OFFSET 3735 3735 } 3736 - 3736 + 3737 3737 printFront(console, "\nMap Editor:\n"); 3738 3738 FOR(const struct HotkeysRowMapEditor*, row, HotkeysTextMapEditor) 3739 3739 { ··· 3744 3744 free(rowReplaced); 3745 3745 #undef OFFSET 3746 3746 } 3747 - 3747 + 3748 3748 printFront(console, "\nSFX Editor:\n"); 3749 3749 FOR(const struct HotkeysRowSFXEditor*, row, HotkeysTextSFXEditor) 3750 3750 { ··· 4002 4002 s32 minor = json_int("minor", 0); 4003 4003 s32 patch = json_int("patch", 0); 4004 4004 4005 - if((major > TIC_VERSION_MAJOR) 4006 - || (major == TIC_VERSION_MAJOR && minor > TIC_VERSION_MINOR) 4005 + if((major > TIC_VERSION_MAJOR) 4006 + || (major == TIC_VERSION_MAJOR && minor > TIC_VERSION_MINOR) 4007 4007 || (major == TIC_VERSION_MAJOR && minor == TIC_VERSION_MINOR && patch > TIC_VERSION_REVISION)) 4008 4008 { 4009 4009 char msg[TICNAME_MAX]; ··· 4359 4359 } 4360 4360 else printBack(console, "\n loading cart..."); 4361 4361 } 4362 - 4362 + 4363 4363 tic_api_cls(tic, TIC_COLOR_BG); 4364 4364 drawConsoleText(console); 4365 4365 ··· 4579 4579 exit(1); 4580 4580 } 4581 4581 else 4582 - getStartScreen(console->studio)->embed = true; 4582 + getStartScreen(console->studio)->embed = true; 4583 4583 } 4584 4584 4585 4585 console->active = !start->embed;
+1 -1
src/studio/screens/console.h
··· 92 92 93 93 bool active; 94 94 StartArgs args; 95 - 95 + 96 96 struct 97 97 { 98 98 s32 count;
+26 -26
src/studio/screens/mainmenu.c
··· 51 51 52 52 static void showMainMenu(void* data, s32 pos); 53 53 54 - StudioMainMenu* studio_mainmenu_init(Menu *menu, Config *config) 54 + StudioMainMenu* studio_mainmenu_init(Menu *menu, Config *config) 55 55 { 56 56 StudioMainMenu* main = NEW(StudioMainMenu); 57 57 ··· 102 102 static const char OffValue[] = "OFF"; 103 103 static const char OnValue[] = "ON"; 104 104 105 - static MenuOption FullscreenOption = 105 + static MenuOption FullscreenOption = 106 106 { 107 107 OPTION_VALUES({OffValue, OnValue}), 108 108 optionFullscreenGet, ··· 121 121 main->options->integerScale = (pos == 1); 122 122 } 123 123 124 - static MenuOption IntegerScaleOption = 124 + static MenuOption IntegerScaleOption = 125 125 { 126 126 OPTION_VALUES({OffValue, OnValue}), 127 127 optionIntegerScaleGet, ··· 141 141 main->options->crt = pos == 1; 142 142 } 143 143 144 - static MenuOption CrtMonitorOption = 144 + static MenuOption CrtMonitorOption = 145 145 { 146 146 OPTION_VALUES({OffValue, OnValue}), 147 147 optionCrtMonitorGet, ··· 162 162 main->options->vsync = pos == 1; 163 163 } 164 164 165 - static MenuOption VSyncOption = 165 + static MenuOption VSyncOption = 166 166 { 167 167 OPTION_VALUES({OffValue, OnValue}), 168 168 optionVSyncGet, ··· 181 181 main->options->volume = pos; 182 182 } 183 183 184 - static MenuOption VolumeOption = 184 + static MenuOption VolumeOption = 185 185 { 186 186 OPTION_VALUES( 187 187 { 188 - "00", "01", "02", "03", 189 - "04", "05", "06", "07", 190 - "08", "09", "10", "11", 191 - "12", "13", "14", "15", 188 + "00", "01", "02", "03", 189 + "04", "05", "06", "07", 190 + "08", "09", "10", "11", 191 + "12", "13", "14", "15", 192 192 }), 193 193 optionVolumeGet, 194 194 optionVolumeSet, ··· 278 278 main->options->keybindMode = (enum KeybindMode) pos; 279 279 } 280 280 281 - static MenuOption KeybindModeOption = 281 + static MenuOption KeybindModeOption = 282 282 { 283 283 OPTION_VALUES({"STANDARD", "EMACS", "VI"}), 284 284 optionKeybindModeGet, ··· 364 364 { 365 365 StudioMainMenu* main = data; 366 366 367 - studio_menu_init(main->menu, EditorMenu, 367 + studio_menu_init(main->menu, EditorMenu, 368 368 COUNT_OF(EditorMenu), EditorMenu_KeybindMode, OptionsMenu_Editor, showOptionsMenu, main); 369 369 } 370 370 #endif ··· 420 420 items[count - 1] = (MenuItem){strdup("BACK"), showMainMenu, .back = true}; 421 421 422 422 main->items = items; 423 - main->count = count; 423 + main->count = count; 424 424 } 425 425 } 426 426 } ··· 514 514 515 515 static char MappingItems[TIC_BUTTONS][sizeof "RIGHT - RIGHT"]; 516 516 517 - static const char* const ButtonLabels[] = 517 + static const char* const ButtonLabels[] = 518 518 { 519 519 "UP", 520 520 "DOWN", ··· 570 570 static const char* const KeysList[] = 571 571 { 572 572 "...", 573 - "A", "B", "C", "D", "E", "F", "G", "H", 574 - "I", "J", "K", "L", "M", "N", "O", "P", 575 - "Q", "R", "S", "T", "U", "V", "W", "X", 576 - "Y", "Z", "0", "1", "2", "3", "4", "5", 577 - "6", "7", "8", "9", "-", "=", "[", "]", 578 - "\\", ";", "'", "`", ",", ".", "/", "SPCE", 579 - "TAB", "RET", "BACKS","DEL", "INS", "PGUP", "PGDN", "HOME", 580 - "END", "UP", "DOWN", "LEFT", "RIGHT","CAPS", "CTRL", "SHIFT", 581 - "ALT", "ESC", "F1", "F2", "F3", "F4", "F5", "F6", 573 + "A", "B", "C", "D", "E", "F", "G", "H", 574 + "I", "J", "K", "L", "M", "N", "O", "P", 575 + "Q", "R", "S", "T", "U", "V", "W", "X", 576 + "Y", "Z", "0", "1", "2", "3", "4", "5", 577 + "6", "7", "8", "9", "-", "=", "[", "]", 578 + "\\", ";", "'", "`", ",", ".", "/", "SPCE", 579 + "TAB", "RET", "BACKS","DEL", "INS", "PGUP", "PGDN", "HOME", 580 + "END", "UP", "DOWN", "LEFT", "RIGHT","CAPS", "CTRL", "SHIFT", 581 + "ALT", "ESC", "F1", "F2", "F3", "F4", "F5", "F6", 582 582 "F7", "F8", "F9", "F10", "F11", "F12", "NP0", "NP1", 583 583 "NP2", "NP3", "NP4", "NP5", "NP6", "NP7", "NP8", "NP9", 584 584 "NP+", "NP-", "NP*", "NP/", "NPENT", "NP.", ··· 601 601 initGamepadButtons(main); 602 602 } 603 603 604 - static MenuOption GamepadOption = 604 + static MenuOption GamepadOption = 605 605 { 606 606 OPTION_VALUES({"1", "2", "3", "4"}), 607 607 optionGamepadGet, ··· 648 648 649 649 initGamepadButtons(main); 650 650 651 - studio_menu_init(main->menu, GamepadMenu, COUNT_OF(GamepadMenu), 652 - main->gamepads.key < 0 ? GamepadMenu_Gamepad0 : main->gamepads.key + GamepadMenu_Gamepad0, 651 + studio_menu_init(main->menu, GamepadMenu, COUNT_OF(GamepadMenu), 652 + main->gamepads.key < 0 ? GamepadMenu_Gamepad0 : main->gamepads.key + GamepadMenu_Gamepad0, 653 653 OptionsMenu_Gamepad, showOptionsMenu, main); 654 654 655 655 main->gamepads.key = -1;
+10 -10
src/studio/screens/menu.c
··· 254 254 { 255 255 playSystemSfx(menu->studio, 2); 256 256 updateOption(option, +1, menu->data); 257 - } 257 + } 258 258 } 259 259 260 260 if(tic_api_btnp(menu->tic, A, -1, -1) || ticEnterWasPressed(tic, -1, -1)) ··· 268 268 onMenuItem(menu, item); 269 269 } 270 270 271 - if((tic_api_btnp(menu->tic, B, -1, -1) 272 - || tic_api_keyp(tic, tic_key_backspace, Hold, Period)) 271 + if((tic_api_btnp(menu->tic, B, -1, -1) 272 + || tic_api_keyp(tic, tic_key_backspace, Hold, Period)) 273 273 && menu->back) 274 274 { 275 275 playSystemSfx(menu->studio, 2); ··· 282 282 { 283 283 s32 width = it->option ? menu->maxwidth.item + menu->maxwidth.option + 3 * TIC_FONT_WIDTH : it->width; 284 284 285 - tic_rect rect = {x + (TIC80_WIDTH - width) / 2 + menu->anim.offset, 285 + tic_rect rect = {x + (TIC80_WIDTH - width) / 2 + menu->anim.offset, 286 286 y + TextMargin + ItemHeight * (i - menu->pos) - menu->anim.pos, it->width, TIC_FONT_HEIGHT}; 287 287 288 288 if (it->hotkey != tic_key_unknown && tic_api_keyp(tic, it->hotkey, Hold, Period)) ··· 320 320 if(it->option) 321 321 { 322 322 drawOptionArrow(menu, it->option, rect.x + menu->maxwidth.item + TIC_FONT_WIDTH, rect.y, tic_icon_left, -1); 323 - drawOptionArrow(menu, it->option, 323 + drawOptionArrow(menu, it->option, 324 324 rect.x + menu->maxwidth.item + it->option->width + 2 * TIC_FONT_WIDTH, rect.y, tic_icon_right, +1); 325 325 326 - printShadow(tic, it->option->values[it->option->pos], 326 + printShadow(tic, it->option->values[it->option->pos], 327 327 rect.x + menu->maxwidth.item + 2 * TIC_FONT_WIDTH, rect.y, tic_color_yellow); 328 328 } 329 329 } ··· 341 341 s32 ly = Gap - 8 * 32 * 16 / (x - ticks % 16); 342 342 343 343 tic_api_line(tic, 0, ly, TIC80_WIDTH, ly, BG_ANIM_COLOR); 344 - tic_api_line(tic, 0, TIC80_HEIGHT - ly, 344 + tic_api_line(tic, 0, TIC80_HEIGHT - ly, 345 345 TIC80_WIDTH, TIC80_HEIGHT - ly, BG_ANIM_COLOR); 346 346 } 347 347 348 348 for(s32 x = -32; x <= 32; x++) 349 349 { 350 - tic_api_line(tic, TIC80_WIDTH / 2 - x * 4, Gap - 16, 350 + tic_api_line(tic, TIC80_WIDTH / 2 - x * 4, Gap - 16, 351 351 TIC80_WIDTH / 2 - x * 24, -16, BG_ANIM_COLOR); 352 352 353 - tic_api_line(tic, TIC80_WIDTH / 2 - x * 4, TIC80_HEIGHT - Gap + 16, 353 + tic_api_line(tic, TIC80_WIDTH / 2 - x * 4, TIC80_HEIGHT - Gap + 16, 354 354 TIC80_WIDTH / 2 - x * 24, TIC80_HEIGHT + 16, BG_ANIM_COLOR); 355 355 } 356 356 } ··· 438 438 else 439 439 { 440 440 s32 pos = menu->pos + (input->mouse.scrolly < 0 ? +1 : -1); 441 - menu->pos = CLAMP(pos, 0, menu->count - 1); 441 + menu->pos = CLAMP(pos, 0, menu->count - 1); 442 442 } 443 443 } 444 444 }
+2 -2
src/studio/screens/run.c
··· 54 54 { 55 55 const char *str = data; 56 56 MD5_CTX c; 57 - 57 + 58 58 static char out[33]; 59 59 60 60 MD5_Init(&c); 61 61 62 - while (length > 0) 62 + while (length > 0) 63 63 { 64 64 MD5_Update(&c, str, length > 512 ? 512: length); 65 65
+1 -1
src/studio/screens/run.h
··· 36 36 tic_tick_data tickData; 37 37 38 38 bool exit; 39 - 39 + 40 40 char saveid[TICNAME_MAX]; 41 41 tic_persistent pmem; 42 42
+17 -17
src/studio/screens/start.c
··· 47 47 static void drawHeader(Start* start) 48 48 { 49 49 for(s32 i = 0; i < STUDIO_TEXT_BUFFER_SIZE; i++) 50 - tic_api_print(start->tic, (char[]){start->text[i], '\0'}, 51 - (i % STUDIO_TEXT_BUFFER_WIDTH) * STUDIO_TEXT_WIDTH, 52 - (i / STUDIO_TEXT_BUFFER_WIDTH) * STUDIO_TEXT_HEIGHT, 50 + tic_api_print(start->tic, (char[]){start->text[i], '\0'}, 51 + (i % STUDIO_TEXT_BUFFER_WIDTH) * STUDIO_TEXT_WIDTH, 52 + (i / STUDIO_TEXT_BUFFER_WIDTH) * STUDIO_TEXT_HEIGHT, 53 53 start->color[i], true, 1, false); 54 54 } 55 55 56 - static void chime(Start* start) 56 + static void chime(Start* start) 57 57 { 58 58 playSystemSfx(start->studio, 1); 59 59 } 60 60 61 - static void stop_chime(Start* start) 61 + static void stop_chime(Start* start) 62 62 { 63 63 sfx_stop(start->tic, 0); 64 64 } ··· 76 76 77 77 static void tick(Start* start) 78 78 { 79 - // stages that have a tick count of 0 run in zero time 79 + // stages that have a tick count of 0 run in zero time 80 80 // (typically this is only used to start/stop audio) 81 81 while (start->stages[start->stage].ticks == 0) { 82 82 start->stages[start->stage].fn(start); ··· 131 131 .embed = false, 132 132 .ticks = 0, 133 133 .stage = 0, 134 - .stages = 134 + .stages = 135 135 { 136 136 { reset, .ticks = one_second }, 137 137 { chime, .ticks = immediate }, ··· 141 141 } 142 142 }; 143 143 144 - static const char* Header[] = 144 + static const char* Header[] = 145 145 { 146 146 "", 147 147 " " TIC_NAME_FULL, ··· 153 153 strcpy(&start->text[i * STUDIO_TEXT_BUFFER_WIDTH], Header[i]); 154 154 155 155 for(s32 i = 0; i < STUDIO_TEXT_BUFFER_SIZE; i++) 156 - start->color[i] = CLAMP(((i % STUDIO_TEXT_BUFFER_WIDTH) + (i / STUDIO_TEXT_BUFFER_WIDTH)) / 2, 156 + start->color[i] = CLAMP(((i % STUDIO_TEXT_BUFFER_WIDTH) + (i / STUDIO_TEXT_BUFFER_WIDTH)) / 2, 157 157 tic_color_black, tic_color_dark_grey); 158 158 159 159 #if defined(__EMSCRIPTEN__) ··· 175 175 176 176 { 177 177 const char* appPath = fs_apppath(); 178 - 178 + 179 179 s32 appSize = 0; 180 180 u8* app = fs_read(appPath, &appSize); 181 - 181 + 182 182 if(app) SCOPE(free(app)) 183 183 { 184 184 s32 size = appSize; 185 185 const u8* ptr = app; 186 - 186 + 187 187 while(true) 188 188 { 189 189 const EmbedHeader* header = (const EmbedHeader*)_memmem(ptr, size, CART_SIG, STRLEN(CART_SIG)); 190 - 190 + 191 191 if(header) 192 192 { 193 193 if(appSize == header->appSize + sizeof(EmbedHeader) + header->cartSize) 194 194 { 195 195 u8* data = calloc(1, sizeof(tic_cartridge)); 196 - 196 + 197 197 if(data) 198 198 { 199 199 s32 dataSize = tic_tool_unzip(data, sizeof(tic_cartridge), app + header->appSize + sizeof(EmbedHeader), header->cartSize); 200 - 200 + 201 201 if(dataSize) 202 202 { 203 203 tic_cart_load(&start->tic->cart, data, dataSize); 204 204 tic_api_reset(start->tic); 205 205 start->embed = true; 206 206 } 207 - 207 + 208 208 free(data); 209 209 } 210 - 210 + 211 211 break; 212 212 } 213 213 else
+13 -13
src/studio/screens/surf.c
··· 138 138 tic_api_print(tic, label, xl, yl, tic_color_white, true, 1, false); 139 139 } 140 140 141 - #ifdef CAN_OPEN_URL 141 + #ifdef CAN_OPEN_URL 142 142 143 143 if(surf->menu.count > 0 && getMenuItem(surf)->hash) 144 144 { ··· 171 171 { 172 172 const char* name = surf->menu.items[i].label; 173 173 174 - if (ym > (-(TIC_FONT_HEIGHT + 1)) && ym <= TIC80_HEIGHT) 174 + if (ym > (-(TIC_FONT_HEIGHT + 1)) && ym <= TIC80_HEIGHT) 175 175 { 176 176 tic_api_print(tic, name, x + MAIN_OFFSET, ym + 1, tic_color_black, false, 1, false); 177 177 tic_api_print(tic, name, x + MAIN_OFFSET, ym, tic_color_white, false, 1, false); ··· 190 190 191 191 static const char CartExt[] = CART_EXT; 192 192 193 - if(dir 193 + if(dir 194 194 || tic_tool_has_ext(name, CartExt) 195 195 || tic_tool_has_ext(name, PngExt) 196 196 #if defined(TIC80_PRO) ··· 297 297 item->cover = malloc(sizeof(tic_screen)); 298 298 item->palette = malloc(sizeof(tic_palette)); 299 299 300 - if (image->width == TIC80_WIDTH 301 - && image->height == TIC80_HEIGHT 300 + if (image->width == TIC80_WIDTH 301 + && image->height == TIC80_HEIGHT 302 302 && image->colors <= TIC_PALETTE_SIZE) 303 303 { 304 304 memcpy(item->palette, image->palette, image->colors * sizeof(tic_rgb)); ··· 378 378 static void loadCover(Surf* surf) 379 379 { 380 380 tic_mem* tic = surf->tic; 381 - 381 + 382 382 SurfItem* item = getMenuItem(surf); 383 - 383 + 384 384 if(item->coverLoading) 385 385 return; 386 386 ··· 431 431 } 432 432 else if(item->hash && !item->cover) 433 433 { 434 - requestCover(surf, item); 434 + requestCover(surf, item); 435 435 } 436 436 } 437 437 ··· 685 685 || ticEnterWasPressed(tic, -1, -1)) 686 686 { 687 687 SurfItem* item = getMenuItem(surf); 688 - item->dir 689 - ? changeDirectory(surf, item->name) 688 + item->dir 689 + ? changeDirectory(surf, item->name) 690 690 : loadCart(surf); 691 691 } 692 692 ··· 855 855 .init = false, 856 856 .loading = true, 857 857 .resume = resume, 858 - .menu = 858 + .menu = 859 859 { 860 860 .pos = 0, 861 861 .items = NULL, ··· 885 885 886 886 .move = MOVIE_DEF(9, moveDone, {{0, 0, 9, &surf->anim.val.pos, AnimLinear}}), 887 887 888 - .gotodir = 888 + .gotodir = 889 889 { 890 890 .show = MOVIE_DEF(ANIM, setIdle, 891 891 { ··· 900 900 }), 901 901 }, 902 902 903 - .goback = 903 + .goback = 904 904 { 905 905 .show = MOVIE_DEF(ANIM, setIdle, 906 906 {
+69 -69
src/studio/studio.c
··· 428 428 bool shift = tic_api_key(tic, tic_key_shift); 429 429 430 430 return caps 431 - ? key >= tic_key_a && key <= tic_key_z 431 + ? key >= tic_key_a && key <= tic_key_z 432 432 ? shift ? Symbols[key] : Shift[key] 433 433 : shift ? Shift[key] : Symbols[key] 434 434 : shift ? Shift[key] : Symbols[key]; ··· 600 600 if (remove_white_spaces) 601 601 removeWhiteSpaces(clipboard); 602 602 603 - bool valid = sameSize 604 - ? strlen(clipboard) == size * 2 603 + bool valid = sameSize 604 + ? strlen(clipboard) == size * 2 605 605 : strlen(clipboard) <= size * 2; 606 606 607 607 if(valid) tic_tool_str2buf(clipboard, (s32)strlen(clipboard), data, flip); ··· 625 625 s32 x = (COUNT_OF(Modes) + 1) * Size + 17 * TIC_FONT_WIDTH; 626 626 s32 y = 0; 627 627 628 - static struct Icon {u8 id; StudioEvent event; const char* tip;} Icons[] = 628 + static struct Icon {u8 id; StudioEvent event; const char* tip;} Icons[] = 629 629 { 630 630 {tic_icon_cut, TIC_TOOLBAR_CUT, "CUT [ctrl+x]"}, 631 631 {tic_icon_copy, TIC_TOOLBAR_COPY, "COPY [ctrl+c]"}, ··· 737 737 738 738 if(checkMouseClick(studio, &rect, tic_mouse_left)) 739 739 { 740 - if(studio->bank.chained) 740 + if(studio->bank.chained) 741 741 memset(studio->bank.indexes, i, sizeof studio->bank.indexes); 742 742 else studio->bank.indexes[mode] = i; 743 743 } ··· 746 746 if(i == studio->bank.indexes[mode]) 747 747 tic_api_rect(tic, rect.x, rect.y, rect.w, rect.h, tic_color_red); 748 748 749 - tic_api_print(tic, (char[]){'0' + i, '\0'}, rect.x+1, rect.y+1, 750 - i == studio->bank.indexes[mode] 751 - ? tic_color_white 752 - : over 753 - ? tic_color_red 754 - : tic_color_light_grey, 749 + tic_api_print(tic, (char[]){'0' + i, '\0'}, rect.x+1, rect.y+1, 750 + i == studio->bank.indexes[mode] 751 + ? tic_color_white 752 + : over 753 + ? tic_color_red 754 + : tic_color_light_grey, 755 755 false, 1, false); 756 756 757 757 } ··· 796 796 { 797 797 const float n1 = 7.5625; 798 798 const float d1 = 2.75; 799 - 799 + 800 800 if (x < 1 / d1) return n1 * x * x; 801 801 else if (x < 2 / d1) 802 - { 802 + { 803 803 x -= 1.5 / d1; 804 804 return n1 * x * x + 0.75; 805 - } 805 + } 806 806 else if (x < 2.5 / d1) 807 - { 807 + { 808 808 x -= 2.25 / d1; 809 809 return n1 * x * x + 0.9375; 810 - } 810 + } 811 811 else 812 812 { 813 813 x -= 2.625 / d1; ··· 984 984 enum{Width = TIC80_WIDTH, Height = TIC_FONT_HEIGHT + 1}; 985 985 986 986 tic_api_rect(studio->tic, 0, studio->anim.pos.popup, Width, Height, tic_color_red); 987 - tic_api_print(studio->tic, studio->popup.message, 987 + tic_api_print(studio->tic, studio->popup.message, 988 988 (s32)(Width - strlen(studio->popup.message) * TIC_FONT_WIDTH)/2, 989 989 studio->anim.pos.popup + 1, tic_color_white, true, 1, false); 990 990 ··· 997 997 for(s32 i = 0, y = 0; y < (Height + studio->anim.pos.popup); y++, dst += TIC80_MARGIN_RIGHT + TIC80_MARGIN_LEFT) 998 998 for(s32 x = 0; x < Width; x++) 999 999 *dst++ = tic_rgba(&bank->palette.vbank0.colors[tic_tool_peek4(tic->ram->vram.screen.data, i++)]); 1000 - } 1000 + } 1001 1001 } 1002 1002 } 1003 1003 ··· 1078 1078 { 1079 1079 switch(studio->mode) 1080 1080 { 1081 - case TIC_CODE_MODE: 1081 + case TIC_CODE_MODE: 1082 1082 { 1083 1083 Code* code = studio->code; 1084 - code->event(code, event); 1084 + code->event(code, event); 1085 1085 } 1086 1086 break; 1087 - case TIC_SPRITE_MODE: 1087 + case TIC_SPRITE_MODE: 1088 1088 { 1089 1089 Sprite* sprite = studio->banks.sprite[studio->bank.index.sprites]; 1090 - sprite->event(sprite, event); 1090 + sprite->event(sprite, event); 1091 1091 } 1092 1092 break; 1093 1093 case TIC_MAP_MODE: ··· 1165 1165 1166 1166 confirmDialog(studio, Rows, COUNT_OF(Rows), exitConfirm, NULL); 1167 1167 } 1168 - else 1168 + else 1169 1169 #endif 1170 1170 exitConfirm(studio, true, NULL); 1171 1171 } ··· 1196 1196 1197 1197 static void initRunMode(Studio* studio) 1198 1198 { 1199 - initRun(studio->run, 1199 + initRun(studio->run, 1200 1200 #if defined(BUILD_EDITORS) 1201 - studio->console, 1201 + studio->console, 1202 1202 #else 1203 1203 NULL, 1204 1204 #endif ··· 1334 1334 1335 1335 static inline bool pointInRect(const tic_point* pt, const tic_rect* rect) 1336 1336 { 1337 - return (pt->x >= rect->x) 1338 - && (pt->x < (rect->x + rect->w)) 1337 + return (pt->x >= rect->x) 1338 + && (pt->x < (rect->x + rect->w)) 1339 1339 && (pt->y >= rect->y) 1340 1340 && (pt->y < (rect->y + rect->h)); 1341 1341 } ··· 1431 1431 { 1432 1432 studio->menuMode = studio->mode; 1433 1433 } 1434 - 1434 + 1435 1435 setStudioMode(studio, TIC_MENU_MODE); 1436 1436 1437 - static MenuItem Answers[] = 1437 + static MenuItem Answers[] = 1438 1438 { 1439 1439 {"", NULL}, 1440 1440 {"(N)O", confirmNo}, ··· 1585 1585 memset(fftNormalizedMaxData, 0, sizeof(fftNormalizedMaxData[0]) * FFT_SIZE); 1586 1586 } 1587 1587 1588 - if(studio->console->args.keepcmd 1588 + if(studio->console->args.keepcmd 1589 1589 && studio->console->commands.count 1590 1590 && studio->console->commands.current >= studio->console->commands.count) 1591 1591 { ··· 1749 1749 for(s32 i = 0; i < COUNT_OF(BankModes); i++) 1750 1750 if(BankModes[i] == studio->mode) 1751 1751 { 1752 - if(studio->bank.chained) 1752 + if(studio->bank.chained) 1753 1753 memset(studio->bank.indexes, bank, sizeof studio->bank.indexes); 1754 1754 else studio->bank.indexes[i] = bank; 1755 1755 break; ··· 1758 1758 1759 1759 #endif 1760 1760 1761 - void gotoMenu(Studio* studio) 1761 + void gotoMenu(Studio* studio) 1762 1762 { 1763 1763 setStudioMode(studio, TIC_MENU_MODE); 1764 1764 studio_mainmenu_free(studio->mainmenu); ··· 1772 1772 } 1773 1773 1774 1774 #if defined(BUILD_EDITORS) 1775 - // These three are to fix the f1 hotkey conflict 1775 + // These three are to fix the f1 hotkey conflict 1776 1776 1777 1777 // Add a static variable in studio.c to track the mode switch 1778 1778 static bool justSwitchedToCodeMode = false; ··· 1866 1866 if( 1867 1867 getConfig(studio)->options.keybindMode == KEYBIND_VI 1868 1868 && getStudioViMode(studio) != VI_NORMAL 1869 - ) 1869 + ) 1870 1870 return; 1871 1871 1872 1872 switch(studio->mode) 1873 1873 { 1874 - case TIC_MENU_MODE: 1875 - showGameMenu(studio) 1874 + case TIC_MENU_MODE: 1875 + showGameMenu(studio) 1876 1876 ? studio_menu_back(studio->menu) 1877 - : setStudioMode(studio, studio->prevMode == TIC_RUN_MODE 1878 - ? TIC_CONSOLE_MODE 1877 + : setStudioMode(studio, studio->prevMode == TIC_RUN_MODE 1878 + ? TIC_CONSOLE_MODE 1879 1879 : studio->prevMode); 1880 1880 break; 1881 - case TIC_RUN_MODE: 1882 - showGameMenu(studio) 1881 + case TIC_RUN_MODE: 1882 + showGameMenu(studio) 1883 1883 ? gotoMenu(studio) 1884 - : setStudioMode(studio, studio->prevMode == TIC_RUN_MODE 1885 - ? TIC_CONSOLE_MODE 1884 + : setStudioMode(studio, studio->prevMode == TIC_RUN_MODE 1885 + ? TIC_CONSOLE_MODE 1886 1886 : studio->prevMode); 1887 1887 break; 1888 - case TIC_CONSOLE_MODE: 1888 + case TIC_CONSOLE_MODE: 1889 1889 setStudioMode(studio, TIC_CODE_MODE); 1890 1890 break; 1891 1891 case TIC_CODE_MODE: ··· 1966 1966 "Do you want to reload it?" 1967 1967 }; 1968 1968 1969 - confirmDialog(studio, Rows, COUNT_OF(Rows), reloadConfirm, NULL); 1969 + confirmDialog(studio, Rows, COUNT_OF(Rows), reloadConfirm, NULL); 1970 1970 } 1971 1971 else console->updateProject(console); 1972 1972 } ··· 2088 2088 tic_api_cls(tic, 0); 2089 2089 } 2090 2090 } 2091 - 2091 + 2092 2092 switch(studio->mode) 2093 2093 { 2094 2094 case TIC_START_MODE: studio->start->tick(studio->start); break; ··· 2097 2097 2098 2098 #if defined(BUILD_EDITORS) 2099 2099 case TIC_CONSOLE_MODE: studio->console->tick(studio->console); break; 2100 - case TIC_CODE_MODE: 2100 + case TIC_CODE_MODE: 2101 2101 { 2102 2102 Code* code = studio->code; 2103 2103 code->tick(code); 2104 2104 } 2105 2105 break; 2106 - case TIC_SPRITE_MODE: 2106 + case TIC_SPRITE_MODE: 2107 2107 { 2108 2108 Sprite* sprite = studio->banks.sprite[studio->bank.index.sprites]; 2109 - sprite->tick(sprite); 2109 + sprite->tick(sprite); 2110 2110 } 2111 2111 break; 2112 2112 case TIC_MAP_MODE: ··· 2165 2165 }, 2166 2166 }, 2167 2167 }, 2168 - .alt = 2168 + .alt = 2169 2169 { 2170 2170 { 0 }, 2171 2171 { 2172 2172 { 2173 2173 .width = TIC_ALTFONT_WIDTH, 2174 - .height = TIC_FONT_HEIGHT, 2174 + .height = TIC_FONT_HEIGHT, 2175 2175 }, 2176 2176 }, 2177 2177 } ··· 2268 2268 fwrite(pos, 1, strlen(pos), file); 2269 2269 fwrite(studio->code->src, 1, strlen(studio->code->src), file); 2270 2270 fclose(file); 2271 - } 2271 + } 2272 2272 } 2273 2273 } 2274 2274 ··· 2383 2383 checkChanges(studio); 2384 2384 tic_net_start(studio->net); 2385 2385 #endif 2386 - 2386 + 2387 2387 if(studio->toolbarMode) 2388 2388 { 2389 2389 setStudioMode(studio, studio->toolbarMode); ··· 2392 2392 2393 2393 processMouseStates(studio); 2394 2394 renderStudio(studio); 2395 - 2395 + 2396 2396 { 2397 2397 #if defined(BUILD_EDITORS) 2398 2398 Sprite* sprite = studio->banks.sprite[studio->bank.index.sprites]; 2399 2399 Map* map = studio->banks.map[studio->bank.index.map]; 2400 2400 #endif 2401 2401 2402 - tic_blit_callback callback[TIC_MODES_COUNT] = 2402 + tic_blit_callback callback[TIC_MODES_COUNT] = 2403 2403 { 2404 2404 [TIC_MENU_MODE] = {studio_menu_anim_scanline, NULL, NULL, studio->menu}, 2405 2405 ··· 2478 2478 { 2479 2479 s32 size = tic->product.samples.count; 2480 2480 for(s16* it = tic->product.samples.buffer, *end = it + size; it != end; ++it) 2481 - *it = *it * volume / MAX_VOLUME; 2481 + *it = *it * volume / MAX_VOLUME; 2482 2482 } 2483 2483 } 2484 2484 ··· 2488 2488 if(yes) 2489 2489 { 2490 2490 const char* file = data; 2491 - showPopupMessage(studio, studio->console->loadCart(studio->console, file) 2491 + showPopupMessage(studio, studio->console->loadCart(studio->console, file) 2492 2492 ? "cart successfully loaded :)" 2493 - : "error: cart not loaded :("); 2493 + : "error: cart not loaded :("); 2494 2494 } 2495 2495 } 2496 2496 ··· 2581 2581 2582 2582 static StartArgs parseArgs(s32 argc, char **argv) 2583 2583 { 2584 - static const char *const usage[] = 2584 + static const char *const usage[] = 2585 2585 { 2586 2586 "tic80 [cart] [options]", 2587 2587 NULL, ··· 2596 2596 args.fftlist = 0; 2597 2597 #endif 2598 2598 2599 - struct argparse_option options[] = 2599 + struct argparse_option options[] = 2600 2600 { 2601 2601 OPT_HELP(), 2602 2602 #define CMD_PARAMS_DEF(name, ctype, type, post, help) OPT_##type('\0', #name, &args.name, help), ··· 2693 2693 setbuf(stdout, NULL); 2694 2694 2695 2695 StartArgs args = parseArgs(argc, argv); 2696 - 2696 + 2697 2697 if (args.version) 2698 2698 { 2699 2699 printf("%s\n", TIC_VERSION); ··· 2714 2714 #if defined(BUILD_EDITORS) 2715 2715 .menuMode = TIC_CONSOLE_MODE, 2716 2716 2717 - .bank = 2717 + .bank = 2718 2718 { 2719 2719 .chained = true, 2720 2720 }, 2721 2721 2722 - .anim = 2722 + .anim = 2723 2723 { 2724 - .pos = 2724 + .pos = 2725 2725 { 2726 2726 .popup = -TOOLBAR_SIZE, 2727 2727 }, ··· 2751 2751 2752 2752 if (fs_exists(path)) 2753 2753 { 2754 - studio->fs = tic_fs_create(path, 2754 + studio->fs = tic_fs_create(path, 2755 2755 #if defined(BUILD_EDITORS) 2756 2756 studio->net 2757 2757 #else ··· 2804 2804 studio->mainmenu = NULL; 2805 2805 tic_fs_makedir(studio->fs, TIC_LOCAL); 2806 2806 tic_fs_makedir(studio->fs, TIC_LOCAL_VERSION); 2807 - 2807 + 2808 2808 initConfig(studio->config, studio, studio->fs); 2809 2809 2810 2810 if (studio->config->data.uiScale > maxscale) ··· 2847 2847 studio->bytebattle.limit.lower = args.lowerlimit; 2848 2848 2849 2849 studio->bytebattle.limit.current 2850 - = studio->bytebattle.limit.upper 2850 + = studio->bytebattle.limit.upper 2851 2851 = args.upperlimit; 2852 2852 2853 - studio->bytebattle.battle.left 2854 - = studio->bytebattle.battle.time 2853 + studio->bytebattle.battle.left 2854 + = studio->bytebattle.battle.time 2855 2855 = args.battletime * 60 * 1000; 2856 2856 2857 2857 if (args.fftlist) ··· 2876 2876 if(getBytebattle(studio)) 2877 2877 { 2878 2878 studio->console->tick(studio->console); 2879 - gotoCode(studio); 2879 + gotoCode(studio); 2880 2880 } 2881 2881 else 2882 2882 setStudioMode(studio, TIC_CONSOLE_MODE);
+1 -1
src/studio/system.h
··· 131 131 #if defined(CRT_SHADER_SUPPORT) 132 132 bool crt; 133 133 #endif 134 - 134 + 135 135 bool fullscreen; 136 136 bool vsync; 137 137 bool integerScale;
+5 -5
src/system/baremetalpi/customchargenerator.cpp
··· 1 - #include <circle/chargenerator.h> 2 - #include <assert.h> 3 - #include "customfont.h" 1 + #include <circle/chargenerator.h> 2 + #include <assert.h> 3 + #include "customfont.h" 4 4 5 - #define FIRSTCHAR 0x00 6 - #define LASTCHAR 0xFF 5 + #define FIRSTCHAR 0x00 6 + #define LASTCHAR 0xFF 7 7 #define CHARCOUNT (LASTCHAR - FIRSTCHAR + 1) 8 8 CCharGenerator::CCharGenerator (void) 9 9 : m_nCharWidth (width)
+2 -2
src/system/baremetalpi/customchargenerator.h
··· 3 3 // 4 4 // Circle - A C++ bare metal environment for Raspberry Pi 5 5 // Copyright (C) 2014 R. Stange <rsta2@o2online.de> 6 - // 6 + // 7 7 // This program is free software: you can redistribute it and/or modify 8 8 // it under the terms of the GNU General Public License as published by 9 9 // the Free Software Foundation, either version 3 of the License, or ··· 31 31 unsigned GetCharWidth (void) const; 32 32 unsigned GetCharHeight (void) const; 33 33 unsigned GetUnderline (void) const; 34 - 34 + 35 35 boolean GetPixel (char chAscii, unsigned nPosX, unsigned nPosY) const; 36 36 37 37 private:
+15 -15
src/system/baremetalpi/customscreen.cpp
··· 3 3 // 4 4 // Circle - A C++ bare metal environment for Raspberry Pi 5 5 // Copyright (C) 2014-2018 R. Stange <rsta2@o2online.de> 6 - // 6 + // 7 7 // This program is free software: you can redistribute it and/or modify 8 8 // it under the terms of the GNU General Public License as published by 9 9 // the Free Software Foundation, either version 3 of the License, or ··· 64 64 delete [] m_pBuffer; 65 65 } 66 66 m_pBuffer = 0; 67 - 67 + 68 68 delete m_pFrameBuffer; 69 69 m_pFrameBuffer = 0; 70 70 } ··· 212 212 m_SpinLock.Acquire (); 213 213 214 214 m_bUpdated = TRUE; 215 - 215 + 216 216 InvertCursor (); 217 - 217 + 218 218 const char *pChar = (const char *) pBuffer; 219 219 int nResult = 0; 220 220 221 221 while (nCount--) 222 222 { 223 223 Write (*pChar++); 224 - 224 + 225 225 nResult++; 226 226 } 227 227 228 228 InvertCursor (); 229 - 229 + 230 230 m_bUpdated = FALSE; 231 231 232 232 m_SpinLock.Release (); ··· 393 393 } 394 394 m_nState = ScreenStateStart; 395 395 break; 396 - 396 + 397 397 case 'm': 398 398 SetStandoutMode (m_nParam1); 399 399 m_nState = ScreenStateStart; ··· 519 519 void CScreenDevice::ClearDisplayEnd (void) 520 520 { 521 521 ClearLineEnd (); 522 - 522 + 523 523 unsigned nPosY = m_nCursorY + m_CharGen.GetCharHeight (); 524 524 unsigned nOffset = nPosY * m_nPitch; 525 - 525 + 526 526 TScreenColor *pBuffer = m_pBuffer + nOffset; 527 527 unsigned nSize = m_nSize / sizeof (TScreenColor) - nOffset; 528 - 528 + 529 529 while (nSize--) 530 530 { 531 531 *pBuffer++ = BLACK_COLOR; ··· 615 615 void CScreenDevice::DisplayChar (char chChar) 616 616 { 617 617 // TODO: Insert mode 618 - 618 + 619 619 if (' ' <= (unsigned char) chChar) 620 620 { 621 621 DisplayChar (chChar, m_nCursorX, m_nCursorY, m_Color); ··· 699 699 case 27: 700 700 m_Color = NORMAL_COLOR; 701 701 break; 702 - 702 + 703 703 case 1: 704 704 m_Color = HIGH_COLOR; 705 705 break; ··· 717 717 void CScreenDevice::Tabulator (void) 718 718 { 719 719 unsigned nTabWidth = m_CharGen.GetCharWidth () * 8; 720 - 720 + 721 721 m_nCursorX = ((m_nCursorX + nTabWidth) / nTabWidth) * nTabWidth; 722 722 if (m_nCursorX >= m_nWidth) 723 723 { ··· 780 780 { 781 781 return; 782 782 } 783 - 783 + 784 784 for (unsigned y = m_CharGen.GetUnderline (); y < m_CharGen.GetCharHeight (); y++) 785 785 { 786 786 for (unsigned x = 0; x < m_CharGen.GetCharWidth (); x++) ··· 813 813 { 814 814 return m_pBuffer[m_nPitch * nPosY + nPosX]; 815 815 } 816 - 816 + 817 817 return BLACK_COLOR; 818 818 } 819 819
+1 -1
src/system/baremetalpi/customscreen.h
··· 3 3 // 4 4 // Circle - A C++ bare metal environment for Raspberry Pi 5 5 // Copyright (C) 2014-2018 R. Stange <rsta2@o2online.de> 6 - // 6 + // 7 7 // This program is free software: you can redistribute it and/or modify 8 8 // it under the terms of the GNU General Public License as published by 9 9 // the Free Software Foundation, either version 3 of the License, or
+2 -2
src/system/baremetalpi/kernel.cpp
··· 1 1 // 2 2 // kernel.cpp 3 - // 3 + // 4 4 // This program is free software: you can redistribute it and/or modify 5 5 // it under the terms of the GNU General Public License as published by 6 6 // the Free Software Foundation, either version 3 of the License, or ··· 208 208 { 209 209 210 210 keyspinlock.Acquire(); 211 - // Just copy buttons and axes. 211 + // Just copy buttons and axes. 212 212 gamepad.buttons = pState -> buttons; 213 213 gamepad.naxes = pState -> naxes; 214 214 for (int i = 0; i< pState->naxes; i++)
+3 -3
src/system/baremetalpi/keycodes.h
··· 2 2 3 3 // derived from keymap_it 4 4 5 - static const tic_keycode TicKeyboardCodes[256] = 5 + static const tic_keycode TicKeyboardCodes[256] = 6 6 { 7 7 tic_key_unknown, // KeyNone, 0x00 8 8 tic_key_unknown, // KeyNone, 0x01 ··· 53 53 tic_key_unknown, // C('?'), 0x2E -- ^ 54 54 tic_key_leftbracket, // C('?'), 0x2F -- [ 55 55 tic_key_rightbracket, // '+', 0x30 -- ] 56 - tic_key_unknown, // C('?'), 0x31 57 - tic_key_unknown, // C('?'), 0x32 56 + tic_key_unknown, // C('?'), 0x31 57 + tic_key_unknown, // C('?'), 0x32 58 58 tic_key_unknown, // C('?'), 0x33 -- @ 59 59 tic_key_unknown, // C('?'), 0x34 -- # 60 60 tic_key_backslash, // '\\', 0x35
+1 -1
src/system/baremetalpi/syscore.h
··· 198 198 //dbg("Memory: %p\n", &mMemory); 199 199 //dbg("Snd: %p\n", &mVCHIQSound); 200 200 201 - 201 + 202 202 203 203 dbg("Creating tic80 instance..\n"); 204 204
+1 -1
src/system/baremetalpi/utils.cpp
··· 8 8 9 9 // this functions are absent for circle-stdlib for some reason 10 10 // (maybe i can't link properly). Since they shouldn't be used 11 - // too much, i'll put some stub here. Chmod is ok since we're on 11 + // too much, i'll put some stub here. Chmod is ok since we're on 12 12 // fat anyway, symlink won't work either. ftruncate could break 13 13 // something 14 14
+2 -2
src/system/libretro/libretro-common/include/libretro.h
··· 3196 3196 3197 3197 /* Savestate where you are guaranteed that the same instance will load the save state. 3198 3198 * You can store internal pointers to code or data. 3199 - * It's still a full serialization and deserialization, and could be loaded or saved at any time. 3199 + * It's still a full serialization and deserialization, and could be loaded or saved at any time. 3200 3200 * It won't be written to disk or sent over the network. 3201 3201 */ 3202 3202 RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_INSTANCE = 1, 3203 3203 3204 3204 /* Savestate where you are guaranteed that the same emulator binary will load that savestate. 3205 - * You can skip anything that would slow down saving or loading state but you can not store internal pointers. 3205 + * You can skip anything that would slow down saving or loading state but you can not store internal pointers. 3206 3206 * It won't be written to disk or sent over the network. 3207 3207 * Example: "Second Instance" runahead 3208 3208 */
+1 -1
src/system/libretro/tic80_libretro.c
··· 1182 1182 1183 1183 /** 1184 1184 * libretro callback; Gets region of memory. 1185 - * 1185 + * 1186 1186 * https://github.com/nesbox/TIC-80/wiki/ram 1187 1187 */ 1188 1188 RETRO_API void *retro_get_memory_data(unsigned id)
+3 -3
src/system/n3ds/keyboard.c
··· 254 254 if (changed) { 255 255 // apply to TIC-80 256 256 kbd->render_dirty = true; 257 - 257 + 258 258 tic_kbd->data = 0; 259 259 int buffer_pos = 0; 260 260 for(i = 0; i < kbd->kd_count && buffer_pos < TIC80_KEY_BUFFER; i++) ··· 299 299 // mouse scroll 300 300 tic_mouse->scrollx = 0; 301 301 tic_mouse->scrolly = 0; 302 - 303 - if (curr_clock >= kbd->scroll_debounce) { 302 + 303 + if (curr_clock >= kbd->scroll_debounce) { 304 304 if(key_held & KEY_CSTICK_UP) 305 305 tic_mouse->scrolly = 1; 306 306 else if(key_held & KEY_CSTICK_DOWN)
+3 -3
src/system/n3ds/utils.c
··· 50 50 if (!png_image_begin_read_from_file(&img, name)) { 51 51 return false; 52 52 } 53 - 53 + 54 54 img.format = PNG_FORMAT_ABGR; 55 - 55 + 56 56 if (loc == TEXTURE_TARGET_VRAM) { 57 57 C3D_TexInitVRAM(tex, npot(img.width), npot(img.height), GPU_RGBA8); 58 58 } else { 59 59 C3D_TexInit(tex, npot(img.width), npot(img.height), GPU_RGBA8); 60 60 } 61 61 data = linearAlloc(tex->width * tex->height * sizeof(u32)); 62 - 62 + 63 63 if (!png_image_finish_read(&img, NULL, data, tex->width * sizeof(u32), NULL)) { 64 64 linearFree(data); 65 65 C3D_TexDelete(tex);
+57 -57
src/system/sdl/main.c
··· 72 72 73 73 #define LOCK_MUTEX(MUTEX) SDL_LockMutex(MUTEX); SCOPE(SDL_UnlockMutex(MUTEX)) 74 74 75 - enum 75 + enum 76 76 { 77 77 tic_key_board = tic_keys_count + 1, 78 78 tic_touch_size, ··· 193 193 } audioIn; 194 194 } platform 195 195 #if defined(TOUCH_INPUT_SUPPORT) 196 - = 196 + = 197 197 { 198 198 .gamepad.touch.counter = TOUCH_TIMEOUT, 199 199 .keyboard.touch.useText = false, ··· 302 302 } 303 303 304 304 *stream++ = ((u8*)tic->product.samples.buffer)[tic->product.samples.count * TIC80_SAMPLESIZE - platform.audio.bufferRemaining--]; 305 - } 305 + } 306 306 } 307 307 } 308 308 ··· 358 358 SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(pixels, Size, Size, 359 359 sizeof(s32) * BITS_IN_BYTE, Size * sizeof(s32), 360 360 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); 361 - 361 + 362 362 SCOPE(SDL_FreeSurface(surface)) 363 363 { 364 364 SDL_SetWindowIcon(platform.window, surface); ··· 426 426 { 427 427 texture->gpu = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_RGBA); 428 428 GPU_SetAnchor(texture->gpu, 0, 0); 429 - GPU_SetImageFilter(texture->gpu, GPU_FILTER_NEAREST); 429 + GPU_SetImageFilter(texture->gpu, GPU_FILTER_NEAREST); 430 430 } 431 431 else 432 432 #endif ··· 440 440 static void initTouchKeyboard() 441 441 { 442 442 tic_mem *tic = tic_core_create(TIC80_SAMPLERATE, SCREEN_FORMAT); 443 - 443 + 444 444 SCOPE(tic_core_close(tic)) 445 445 { 446 446 memcpy(tic->ram->vram.palette.data, studio_config(platform.studio)->cart->bank0.palette.vbank0.data, sizeof(tic_palette)); ··· 450 450 initTouchKeyboardState(tic, &platform.keyboard.touch.texture.up, &platform.keyboard.touch.texture.upPixels, false); 451 451 initTouchKeyboardState(tic, &platform.keyboard.touch.texture.down, &platform.keyboard.touch.texture.downPixels, true); 452 452 453 - memset(tic->ram->map.data, 0, sizeof tic->ram->map); 453 + memset(tic->ram->map.data, 0, sizeof tic->ram->map); 454 454 } 455 455 } 456 456 ··· 492 492 if(!platform.gamepad.touch.pixels) 493 493 { 494 494 tic_mem* tic = tic_core_create(TIC80_SAMPLERATE, SCREEN_FORMAT); 495 - 495 + 496 496 SCOPE(tic_core_close(tic)) 497 497 { 498 498 const tic_bank* bank = &studio_config(platform.studio)->cart->bank0; ··· 526 526 platform.gamepad.touch.texture.gpu = GPU_CreateImage(TEXTURE_SIZE, TEXTURE_SIZE, GPU_FORMAT_RGBA); 527 527 GPU_SetAnchor(platform.gamepad.touch.texture.gpu, 0, 0); 528 528 GPU_SetImageFilter(platform.gamepad.touch.texture.gpu, GPU_FILTER_NEAREST); 529 - GPU_SetRGBA(platform.gamepad.touch.texture.gpu, 0xff, 0xff, 0xff, studio_config(platform.studio)->theme.gamepad.touch.alpha); 529 + GPU_SetRGBA(platform.gamepad.touch.texture.gpu, 0xff, 0xff, 0xff, studio_config(platform.studio)->theme.gamepad.touch.alpha); 530 530 } 531 531 else 532 532 #endif 533 533 { 534 - platform.gamepad.touch.texture.sdl = SDL_CreateTexture(platform.screen.renderer.sdl, SDL_PIXELFORMAT_ABGR8888, 534 + platform.gamepad.touch.texture.sdl = SDL_CreateTexture(platform.screen.renderer.sdl, SDL_PIXELFORMAT_ABGR8888, 535 535 SDL_TEXTUREACCESS_STREAMING, TEXTURE_SIZE, TEXTURE_SIZE); 536 536 SDL_SetTextureBlendMode(platform.gamepad.touch.texture.sdl, SDL_BLENDMODE_BLEND); 537 - SDL_SetTextureAlphaMod(platform.gamepad.touch.texture.sdl, studio_config(platform.studio)->theme.gamepad.touch.alpha); 537 + SDL_SetTextureAlphaMod(platform.gamepad.touch.texture.sdl, studio_config(platform.studio)->theme.gamepad.touch.alpha); 538 538 } 539 539 540 540 updateTextureBytes(platform.gamepad.touch.texture, platform.gamepad.touch.pixels, TEXTURE_SIZE, TEXTURE_SIZE); ··· 570 570 else 571 571 #endif 572 572 { 573 - platform.screen.renderer.sdl = SDL_CreateRenderer(platform.window, -1, 573 + platform.screen.renderer.sdl = SDL_CreateRenderer(platform.window, -1, 574 574 #if defined(CRT_SHADER_SUPPORT) 575 575 SDL_RENDERER_SOFTWARE 576 576 #else ··· 579 579 | (!soft && vsync ? SDL_RENDERER_PRESENTVSYNC : 0) 580 580 ); 581 581 582 - platform.screen.texture.sdl = SDL_CreateTexture(platform.screen.renderer.sdl, SDL_PIXELFORMAT_ABGR8888, 582 + platform.screen.texture.sdl = SDL_CreateTexture(platform.screen.renderer.sdl, SDL_PIXELFORMAT_ABGR8888, 583 583 SDL_TEXTUREACCESS_STREAMING, TIC80_FULLWIDTH, TIC80_FULLHEIGHT); 584 584 } 585 585 ··· 619 619 platform.screen.shader = 0; 620 620 } 621 621 622 - GPU_Quit(); 622 + GPU_Quit(); 623 623 } 624 624 625 625 #endif ··· 647 647 648 648 *rect = (SDL_Rect) 649 649 { 650 - (sw - w) / 2, 650 + (sw - w) / 2, 651 651 #if defined (TOUCH_INPUT_SUPPORT) 652 652 // snap the screen up to get a place for the software keyboard 653 653 sw > sh ? (sh - h) / 2 : 0, 654 654 #else 655 - (sh - h) / 2, 655 + (sh - h) / 2, 656 656 #endif 657 657 w, h 658 658 }; ··· 697 697 } 698 698 } 699 699 700 - { 700 + { 701 701 input->mouse.left = mb & SDL_BUTTON_LMASK ? 1 : 0; 702 702 input->mouse.middle = mb & SDL_BUTTON_MMASK ? 1 : 0; 703 703 input->mouse.right = mb & SDL_BUTTON_RMASK ? 1 : 0; ··· 719 719 // it's weird, but system sends CTRL when you press RALT 720 720 if(mod & KMOD_RALT) 721 721 platform.keyboard.state[tic_key_ctrl] = false; 722 - } 722 + } 723 723 724 724 for(s32 i = 0, c = 0; i < COUNT_OF(platform.keyboard.state) && c < TIC80_KEY_BUFFER; i++) 725 - if(platform.keyboard.state[i] 725 + if(platform.keyboard.state[i] 726 726 // Some programmable keyboards will send key down and up events immediately. 727 727 // If the key was pressed and released in the same frame, report it as 728 728 // down for this frame so that it isn't missed. Lying about the key being ··· 808 808 ; 809 809 } 810 810 811 - static const tic_key KbdLayout[] = 811 + static const tic_key KbdLayout[] = 812 812 { 813 813 #include "kbdlayout.inl" 814 814 }; ··· 938 938 static u8 getButton(SDL_GameController* controller, SDL_GameControllerButton button) 939 939 { 940 940 return SDL_GameControllerHasButton(controller, button) 941 - ? SDL_GameControllerGetButton(controller, button) 941 + ? SDL_GameControllerGetButton(controller, button) 942 942 : 0; 943 943 } 944 944 ··· 966 966 967 967 if(gamepad) 968 968 { 969 - gamepad->up = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTY, -1) 969 + gamepad->up = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTY, -1) 970 970 || getAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY, -1) 971 971 || getButton(controller, SDL_CONTROLLER_BUTTON_DPAD_UP); 972 972 973 - gamepad->down = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTY, +1) 973 + gamepad->down = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTY, +1) 974 974 || getAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY, +1) 975 975 || getButton(controller, SDL_CONTROLLER_BUTTON_DPAD_DOWN); 976 976 977 - gamepad->left = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTX, -1) 977 + gamepad->left = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTX, -1) 978 978 || getAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX, -1) 979 979 || getButton(controller, SDL_CONTROLLER_BUTTON_DPAD_LEFT); 980 980 981 - gamepad->right = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTX, +1) 981 + gamepad->right = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTX, +1) 982 982 || getAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX, +1) 983 983 || getButton(controller, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); 984 984 ··· 1009 1009 1010 1010 #if defined(TOUCH_INPUT_SUPPORT) 1011 1011 input->gamepads.data |= platform.gamepad.touch.joystick.data; 1012 - #endif 1012 + #endif 1013 1013 input->gamepads.data |= platform.gamepad.joystick.data; 1014 1014 } 1015 1015 } ··· 1018 1018 static void processTouchInput() 1019 1019 { 1020 1020 s32 devices = SDL_GetNumTouchDevices(); 1021 - 1021 + 1022 1022 for (s32 i = 0; i < devices; i++) 1023 1023 if(SDL_GetNumTouchFingers(SDL_GetTouchDevice(i)) > 0) 1024 1024 { ··· 1033 1033 } 1034 1034 #endif 1035 1035 1036 - static const u32 KeyboardCodes[tic_keys_count] = 1036 + static const u32 KeyboardCodes[tic_keys_count] = 1037 1037 { 1038 1038 #include "keycodes.inl" 1039 1039 }; ··· 1088 1088 { 1089 1089 const tic_mem* tic = studio_mem(platform.studio); 1090 1090 if((bool)tic->ram->input.mouse.relative != (bool)SDL_GetRelativeMouseMode()) 1091 - SDL_SetRelativeMouseMode(tic->ram->input.mouse.relative ? SDL_TRUE : SDL_FALSE); 1091 + SDL_SetRelativeMouseMode(tic->ram->input.mouse.relative ? SDL_TRUE : SDL_FALSE); 1092 1092 } 1093 1093 1094 1094 ZEROMEM(platform.input); ··· 1185 1185 1186 1186 #if defined(TOUCH_INPUT_SUPPORT) 1187 1187 updateGamepadParts(); 1188 - #endif 1188 + #endif 1189 1189 } 1190 1190 break; 1191 1191 #if defined(__LINUX__) 1192 - case SDL_WINDOWEVENT_FOCUS_GAINED: 1192 + case SDL_WINDOWEVENT_FOCUS_GAINED: 1193 1193 // lock input for 10 ticks 1194 1194 lockInput = 10; 1195 1195 break; ··· 1287 1287 { 1288 1288 if(key == KbdLayout[k]) 1289 1289 { 1290 - SDL_Rect src2 = 1290 + SDL_Rect src2 = 1291 1291 { 1292 - (k % Cols) * TIC_SPRITESIZE + TIC80_OFFSET_LEFT, 1293 - (k / Cols) * TIC_SPRITESIZE + TIC80_OFFSET_TOP, 1294 - TIC_SPRITESIZE, 1292 + (k % Cols) * TIC_SPRITESIZE + TIC80_OFFSET_LEFT, 1293 + (k / Cols) * TIC_SPRITESIZE + TIC80_OFFSET_TOP, 1294 + TIC_SPRITESIZE, 1295 1295 TIC_SPRITESIZE, 1296 1296 }; 1297 1297 1298 - SDL_Rect dst2 = 1298 + SDL_Rect dst2 = 1299 1299 { 1300 - (src2.x - TIC80_OFFSET_LEFT) * rect.w/src.w, 1301 - (src2.y - TIC80_OFFSET_TOP) * rect.w/src.w + dst.y, 1302 - TIC_SPRITESIZE * rect.w/src.w, 1300 + (src2.x - TIC80_OFFSET_LEFT) * rect.w/src.w, 1301 + (src2.y - TIC80_OFFSET_TOP) * rect.w/src.w + dst.y, 1302 + TIC_SPRITESIZE * rect.w/src.w, 1303 1303 TIC_SPRITESIZE * rect.w/src.w, 1304 1304 }; 1305 1305 ··· 1425 1425 else 1426 1426 #endif 1427 1427 { 1428 - return SDL_GetWindowFlags(platform.window) & SDL_WINDOW_FULLSCREEN_DESKTOP 1428 + return SDL_GetWindowFlags(platform.window) & SDL_WINDOW_FULLSCREEN_DESKTOP 1429 1429 ? true : false; 1430 1430 } 1431 1431 } ··· 1440 1440 else 1441 1441 #endif 1442 1442 { 1443 - SDL_SetWindowFullscreen(platform.window, 1443 + SDL_SetWindowFullscreen(platform.window, 1444 1444 value ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); 1445 1445 } 1446 1446 } ··· 1509 1509 1510 1510 static void loadCrtShader() 1511 1511 { 1512 - static const char VertextShader[] = 1512 + static const char VertextShader[] = 1513 1513 #if !defined (EMSCRIPTEN) 1514 1514 "#version 110" "\n" 1515 1515 #endif ··· 1527 1527 "}" "\n" 1528 1528 ; 1529 1529 1530 - static const char PixelShader[] = 1530 + static const char PixelShader[] = 1531 1531 #if !defined (EMSCRIPTEN) 1532 1532 "#version 110" "\n" 1533 1533 #else ··· 1663 1663 ; 1664 1664 1665 1665 u32 vertex = GPU_CompileShader(GPU_VERTEX_SHADER, VertextShader); 1666 - 1666 + 1667 1667 if(!vertex) 1668 1668 { 1669 1669 printf("Failed to load vertex shader: %s\n", GPU_GetShaderMessage()); ··· 1671 1671 } 1672 1672 1673 1673 u32 pixel = GPU_CompileShader(GPU_PIXEL_SHADER, PixelShader); 1674 - 1674 + 1675 1675 if(!pixel) 1676 1676 { 1677 1677 printf("Failed to load pixel shader: %s\n", GPU_GetShaderMessage()); 1678 1678 return; 1679 1679 } 1680 - 1680 + 1681 1681 if(platform.screen.shader) 1682 1682 GPU_FreeShaderProgram(platform.screen.shader); 1683 1683 1684 1684 platform.screen.shader = GPU_LinkShaders(vertex, pixel); 1685 - 1685 + 1686 1686 if(platform.screen.shader) 1687 1687 { 1688 1688 platform.screen.block = GPU_LoadShaderBlock(platform.screen.shader, "gpu_Vertex", "gpu_TexCoord", "gpu_Color", "gpu_ModelViewProjectionMatrix"); ··· 1705 1705 1706 1706 void tic_sys_default_mapping(tic_mapping* mapping) 1707 1707 { 1708 - static const SDL_Scancode Scancodes[] = 1708 + static const SDL_Scancode Scancodes[] = 1709 1709 { 1710 1710 SDL_SCANCODE_UP, 1711 1711 SDL_SCANCODE_DOWN, ··· 1783 1783 s32 w, h; 1784 1784 SDL_GetWindowSize(platform.window, &w, &h); 1785 1785 1786 - s32 offset = tic->ram->input.mouse.x < TIC80_FULLHEIGHT / 2 1786 + s32 offset = tic->ram->input.mouse.x < TIC80_FULLHEIGHT / 2 1787 1787 ? TIC80_FULLWIDTH-TIC80_OFFSET_LEFT : 0; 1788 1788 1789 - const SDL_Rect Src[] = 1789 + const SDL_Rect Src[] = 1790 1790 { 1791 1791 {offset, 0, TIC80_OFFSET_LEFT, TIC80_OFFSET_TOP}, // top border 1792 1792 {offset, TIC80_FULLHEIGHT-TIC80_OFFSET_TOP, TIC80_OFFSET_LEFT, TIC80_OFFSET_TOP}, // bottom border ··· 1795 1795 {0, 0, TIC80_FULLWIDTH, TIC80_FULLHEIGHT}, // center 1796 1796 }; 1797 1797 1798 - const SDL_Rect Dst[] = 1798 + const SDL_Rect Dst[] = 1799 1799 { 1800 1800 {0, 0, w, rect.y}, // top border 1801 1801 {0, rect.y + rect.h, w, h - (rect.y + rect.h)}, // bottom border ··· 1934 1934 const s32 Width = TIC80_FULLWIDTH * studio_config(platform.studio)->uiScale; 1935 1935 const s32 Height = TIC80_FULLHEIGHT * studio_config(platform.studio)->uiScale; 1936 1936 1937 - s32 flags = SDL_WINDOW_SHOWN 1937 + s32 flags = SDL_WINDOW_SHOWN 1938 1938 #if !defined(__EMSCRIPTEN__) && !defined(__MACOSX__) 1939 1939 | SDL_WINDOW_ALLOW_HIGHDPI 1940 1940 #endif ··· 1944 1944 1945 1945 if(!studio_config(platform.studio)->soft) 1946 1946 flags |= SDL_WINDOW_OPENGL; 1947 - #endif 1947 + #endif 1948 1948 1949 1949 platform.window = SDL_CreateWindow(TIC_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, flags); 1950 1950 ··· 1995 1995 1996 1996 if(platform.keyboard.touch.texture.downPixels) 1997 1997 SDL_free(platform.keyboard.touch.texture.downPixels); 1998 - #endif 1998 + #endif 1999 1999 2000 2000 SDL_DestroyWindow(platform.window); 2001 2001 SDL_CloseAudioDevice(platform.audio.device); ··· 2058 2058 2059 2059 Module.filePreloaded = false; 2060 2060 2061 - FS.createPreloadedFile(dir, PATH.basename(file), UTF8ToString($3), true, true, 2061 + FS.createPreloadedFile(dir, PATH.basename(file), UTF8ToString($3), true, true, 2062 2062 function() 2063 2063 { 2064 2064 Module.filePreloaded = true; ··· 2104 2104 Module.syncFSRequests = 0; 2105 2105 2106 2106 var dir = UTF8ToString($0); 2107 - 2107 + 2108 2108 FS.mkdirTree(dir); 2109 2109 2110 2110 FS.mount(IDBFS, {}, dir); ··· 2119 2119 #else 2120 2120 2121 2121 return start(argc, argv, folder); 2122 - 2122 + 2123 2123 #endif 2124 2124 } 2125 2125
+3 -3
src/system/sdl/player.c
··· 73 73 } 74 74 75 75 *stream++ = ((u8*)tic->samples.buffer)[tic->samples.count * TIC80_SAMPLESIZE - state.remaining--]; 76 - } 76 + } 77 77 } 78 78 SDL_UnlockMutex(state.mutex); 79 79 } ··· 94 94 fprintf(stderr, "Failed to load cart data."); 95 95 output = 1; 96 96 } 97 - else 97 + else 98 98 { 99 99 SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); 100 100 ··· 124 124 u64 nextTick = SDL_GetPerformanceCounter(); 125 125 126 126 SDL_PauseAudioDevice(audioDevice, 0); 127 - 127 + 128 128 while(!state.quit) 129 129 { 130 130 SDL_Event event;
+4 -4
src/tic.h
··· 175 175 176 176 typedef struct 177 177 { 178 - 178 + 179 179 struct 180 180 { 181 181 #if RETRO_IS_BIG_ENDIAN ··· 353 353 s8 frame; 354 354 s8 row; 355 355 } music; 356 - 356 + 357 357 struct 358 358 { 359 359 #if RETRO_IS_BIG_ENDIAN ··· 607 607 608 608 u8 reserved[3]; 609 609 }; 610 - 610 + 611 611 u8 data[TIC_VRAM_SIZE]; 612 612 } tic_vram; 613 613 ··· 707 707 tic_key_comma, 708 708 tic_key_period, 709 709 tic_key_slash, 710 - 710 + 711 711 tic_key_space, 712 712 tic_key_tab, 713 713
+1 -1
src/tic_assert.h
··· 4 4 #define static_assert _Static_assert 5 5 #endif 6 6 7 - #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 7 + #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 8 8 #define static_assert__(x,line) static char stat_ass ## line[(x) ? +1 : -1] 9 9 #define static_assert_(x,line) static_assert__(x,line) 10 10 #define static_assert(x,y) static_assert_(x, __LINE__)
+1 -1
src/tilesheet.c
··· 26 26 #include <stdlib.h> 27 27 28 28 static const tic_blit_segment segments[] = { 29 - // +page +nb_pages 29 + // +page +nb_pages 30 30 // | +bank +bank_size 31 31 // | | | | +sheet_width 32 32 // | | | | | +tile_width
+1 -1
src/tools.c
··· 67 67 { 68 68 u32 min = -1; 69 69 s32 nearest, i = 0; 70 - 70 + 71 71 for(const tic_rgb *rgb = palette, *end = rgb + count; rgb < end; rgb++, i++) 72 72 { 73 73 s32 d[] = {color->r - rgb->r, color->g - rgb->g, color->b - rgb->b};
+6 -6
templates/c/wasmdemo.wasmp
··· 2 2 -- script: wasm 3 3 4 4 """"""""""""""""""""""""""""""""""""""" 5 - WASM is a binary format. The demo 6 - binary code is embedded in this 5 + WASM is a binary format. The demo 6 + binary code is embedded in this 7 7 cartridge, the source code is not. 8 8 Run the cart to see the demo. 9 9 ··· 11 11 you can't (yet) develop WASM projects 12 12 using the built-in editor. 13 13 14 - The code used to build this project 14 + The code used to build this project 15 15 can be found in the TIC-80 repo: 16 16 17 17 https://github.com/nesbox/TIC-80/templates/c 18 18 19 - This demo was built with C, but many 20 - languages are supported. You simply 19 + This demo was built with C, but many 20 + languages are supported. You simply 21 21 build your project with your external 22 22 compiler, then import the final WASM 23 23 binary into your cartridge: 24 - 24 + 25 25 import binary out.wasm 26 26 27 27 See README.md for details.
+1 -1
templates/d/src/tic80.d
··· 3 3 extern(C): 4 4 5 5 struct MouseData { 6 - short x; short y; 6 + short x; short y; 7 7 byte scrollx; byte scrolly; 8 8 bool left; bool middle; bool right; 9 9 }
+6 -6
templates/d/wasmdemo.wasmp
··· 2 2 -- script: wasm 3 3 4 4 """"""""""""""""""""""""""""""""""""""" 5 - WASM is a binary format. The demo 6 - binary code is embedded in this 5 + WASM is a binary format. The demo 6 + binary code is embedded in this 7 7 cartridge, the source code is not. 8 8 Run the cart to see the demo. 9 9 ··· 11 11 you can't (yet) develop WASM projects 12 12 using the built-in editor. 13 13 14 - The code used to build this project 14 + The code used to build this project 15 15 can be found in the TIC-80 repo: 16 16 17 17 https://github.com/nesbox/TIC-80/templates/d 18 18 19 - This demo was built with D, but many 20 - languages are supported. You simply 19 + This demo was built with D, but many 20 + languages are supported. You simply 21 21 build your project with your external 22 22 compiler, then import the final WASM 23 23 binary into your cartridge: 24 - 24 + 25 25 import binary out.wasm 26 26 27 27 See README.md for details.
+6 -6
templates/zig/cart.wasmp
··· 2 2 -- script: wasm 3 3 4 4 """"""""""""""""""""""""""""""""""""""" 5 - WASM is a binary format. The demo 6 - binary code is embedded in this 5 + WASM is a binary format. The demo 6 + binary code is embedded in this 7 7 cartridge, the source code is not. 8 8 Run the cart to see the demo. 9 9 ··· 11 11 you can't (yet) develop WASM projects 12 12 using the built-in editor. 13 13 14 - The code used to build this project 14 + The code used to build this project 15 15 can be found in the TIC-80 repo: 16 16 17 17 https://github.com/nesbox/TIC-80 18 18 /demos/wasm/ 19 19 20 - This demo was built with Zig, but many 21 - languages are supported. You simply 20 + This demo was built with Zig, but many 21 + languages are supported. You simply 22 22 build your project with your external 23 23 compiler, then import the final WASM 24 24 binary into your cartridge: 25 - 25 + 26 26 import binary out.wasm 27 27 28 28 To learn more visit our Wiki and