I'll better go without LUA - thus way source is more portable.
Thank you for your efforts!
Вид для печати
About being portable... even if I add string operators later, it will not compile in any older/other version of sjasmplus, so as long as we are talking about _VERSION define, the double-warning about overflow seems to be best compromise at this moment
(or putting the string into memory first and read it from there per words, but that feels to me a bit more ugly than initial warnings... although if you do such processing only at start of source, and set up your own defines to distinguish between versions, and you are allergic to warnings, this is still viable option (I think {} works also in other version of sjasmplus? Was already part of Aprisobal's source if I recall it correctly)).
EDIT: the real issue is, that sjasmplus assembly has no data types and pretty much everything is 32bit number except "DB/DZ/.." directives, which will break down strings into separate bytes. So giving user pre-defined _VERSION="1.13.0" is sort of bad joke, because there're very limited ways how to process such value, but that's now "legacy", so there's no simple way out of it.
I don't like it, both in style way, and in the internal implementation way.
I was already checking few weeks back, if it would make sense to add the common C/shellscript/.. way of using backslash at end of line, and I can't recall the details now, but the implementation with current sjasmplus internals wouldn't be particularly easy. The block comment proposal is pretty much the same thing, so it would run into the same problems, and it's even less intuitive than backslash (at least for C programmers), seems like bigger "hack".
So some way to "add" to DEFARRAY is lot more preferred, long multi-line feature is more complicated. There are fixed-size 2048 chars buffers all around the code, and even if you overcome that, there are some things like macro/dup reading the source into string-linked-list buffers of their own, so adding backslash for multi-line would need changes on several places of code, while adding "DEFARRAYADD" is almost single short new-block of code, without risk of breaking some complex state in parsing... Actually I'm mentally still in the process of trying to simplify the line parsing / file reading (to have less code paths and fewer code duplicities), maybe after I will give up on that, I will check again for adding backslash feature, but I don't see much pressure for it. This DEFARRAY is first clear case where it would really help, but most of the other cases can be avoided in reasonable way.
So at this moment the "add" variant has much higher chance, I will maybe try it today if I will find some time along work.
"DEFARRAY+" in github (for next release or if you are building from sources)...
docs: http://z00m128.github.io/sjasmplus/d..._defarray_plus
Example:As expected, implementing this was quite simple... (for "FILL", if you really need it, just create macro like that DUP in example, but I don't expect it to be needed by 99% of users, so I didn't add it natively)Код:DEFARRAY myarray 'A', 'B', 'C'
DEFARRAY+ myarray 'D', 'E' ; now "myarray" has 5 items
DUP 3 : DEFARRAY+ myarray '!' : EDUP ; "DEFARRAYFILL" adding 3x '!'
(but precise targetted overwrite on "from-to" indices would be quite a pain, as internally it's not array, but one direction linked list ... and I don't believe you truly need that, need to see real world case like that, but it sounds like typical "code smell")
Незнаю зачем этот дефарей, мне точно не нужен, для подобного есть луа. Но я тут чутка подумал правильно работающий struct важнее map. Если бы еще убить тупые инфо об incbin то будет вообще отлично.
ну и как запилить массив в луа?
на встроенную луа инструкции то нет...
мне и там нужны заранне просчитанные таблицы на 64К значений
из которых потом выбирать нужные значения
так как проще будет проинтегрировав функцию сначала просмотреть результат в excell-е
чем тыкаться в lua не имея возможности нормально проверить результат графически... (тк нужно много знаков посля запятой)
а я не знаю зачем и кому нужны твои структуры и мапы и как их можно применить...
для снижения читаемости кода?
- - - Добавлено - - -
ссылки на левые статьи не нужно
давай примеры которые переваривает луа в sjasm-е
(которая обычно не берет большую часть команд из lua по ГОСТ-у)
Структуры используются во всех играх, 100%, без них только имитацией тех же структур.
Данные через луа можно загонять прям из той же csv что и в экселе, с парсингом текста луа более менее справляется.
Вообще да, массивы могут пригодится, но не 64к значений, я как то перестал мыслить разложенным кодом, не интересно.
а пример?
- - - Добавлено - - -
чот не уверен :)
- - - Добавлено - - -
ну да это многовато
обычно нужно или совсем мало до 30
или 256...2К
хотя мне ВНЕЗАПНО для одной задачи нужно именно 64К
и чтоб знаков 8 после запятой
или же в луа должно работать goto которого щас нету
тогда можно будет без извращений написать все на луа и даже точнее чем приближенной функцией в екселе...
хотя для єтого все равно было бы лучше если бы были массивы...
идея считать отдельно в бейсике :) мне не нравится
люблю когда можно поменять параметры
и чтоб быстро все пересчиталось самим сджасмом
Did you try various levels of `--msg` option? I'm personally using `sjasmplus --nologo --msg=war --lst --lstlab` for almost everything.
-------
About LUA vs DEFARRAY vs anything:
This is kinda pointless discussion, I personally don't like to use Lua in my asm sources, but if somebody does, it's good they can.
If somebody likes to use DEFARRAY instead, why not, it is already part of sjasmplus.
If you hit real world problem with it, like for example the max-line length limit, maybe it can be fixed/improved (I'm not really proud of the "DEFARRAY+" fix, feels a bit like "hack", but it does solve real problem, so whatever... there are many other "hacks" in sjasmplus already, one more doesn't change the situation much).
Similarly the integrated Lua is somewhat outdated now (I guess?), and it would be probably good to update it, there's nothing wrong about it in principle (just needs somebody with time to develop it, not a priority for me at this moment, maybe later).
And finally the integration of Lua into sjasmplus can be also improved (by adding new operators/etc), again I don't see anything wrong about that, except that it must be developed = somebody must invest their life time into it. (and *I* will still like to avoid Lua, even if it will be updated and improved, but it should work)
I.e. if you can provide example of particular problem, it may get fixed/improved. Real problems get usually more attention than theoretical. :smile:
:biggrin: IMO struct can make often source easier to read, but that's just personal preference.
.. anyway v1.13.1 "soon" ... (the current master on github is IMO ready to be released, just doing final checks and tests - if you are building sjasmplus from github, trying it now on your projects and reporting any issue may be good idea, otherwise 1.13.1 will go out as it is now)
для лучшего понимания для чего нужна lua
вот для примера небольшой кусочек моего raycast-ера
как такое можно написать руками?
рассчитывать на самом спектруме не вариант...
(тк точности после запятой в самой lua уже не хватает...)
в оригинале процедура на 48К :)
- - - Добавлено - - -Код:427 1242 ;======================================================
427 1242 RAY_12_ROUTINE
427 1242 ;======================================================
427 1242 ray12hit1
427 1242 67 ld h,a
427 1243 2E 01 ld l,1
427 1245 E5 push hl
427 1246 C3 43 14 jp castray13
427 1249 ray12hit2
427 1249 67 ld h,a
427 124A 2E 02 ld l,2
427 124C E5 push hl
427 124D C3 43 14 jp castray13
427 1250 ray12hit3
427 1250 67 ld h,a
427 1251 2E 03 ld l,3
427 1253 E5 push hl
427 1254 C3 43 14 jp castray13
427 1257 ray12hit4
427 1257 67 ld h,a
427 1258 2E 04 ld l,4
427 125A E5 push hl
427 125B C3 43 14 jp castray13
427 125E ray12hit5
427 125E 67 ld h,a
427 125F 2E 05 ld l,5
427 1261 E5 push hl
427 1262 C3 43 14 jp castray13
427 1265 ray12hit6
427 1265 67 ld h,a
427 1266 2E 07 ld l,7
427 1268 E5 push hl
427 1269 C3 43 14 jp castray13
427 126C ray12hit7
427 126C 67 ld h,a
427 126D 2E 07 ld l,7
427 126F E5 push hl
427 1270 C3 43 14 jp castray13
427 1273 ray12hit8
427 1273 67 ld h,a
427 1274 2E 09 ld l,9
427 1276 E5 push hl
427 1277 C3 43 14 jp castray13
427 127A ray12hit9
427 127A 67 ld h,a
427 127B 2E 0A ld l,10
427 127D E5 push hl
427 127E C3 43 14 jp castray13
427 1281 ray12hit10
427 1281 67 ld h,a
427 1282 2E 0B ld l,11
427 1284 E5 push hl
427 1285 C3 43 14 jp castray13
427 1288 ray12hit11
427 1288 67 ld h,a
427 1289 2E 0C ld l,12
427 128B E5 push hl
427 128C C3 43 14 jp castray13
427 128F ray12hit12
427 128F 67 ld h,a
427 1290 2E 0E ld l,14
427 1292 E5 push hl
427 1293 C3 43 14 jp castray13
427 1296 ray12hit13
427 1296 67 ld h,a
427 1297 2E 0F ld l,15
427 1299 E5 push hl
427 129A C3 43 14 jp castray13
427 129D ray12hit14
427 129D 67 ld h,a
427 129E 2E 10 ld l,16
427 12A0 E5 push hl
427 12A1 C3 43 14 jp castray13
427 12A4 ray12hit15
427 12A4 67 ld h,a
427 12A5 2E 11 ld l,17
427 12A7 E5 push hl
427 12A8 C3 43 14 jp castray13
427 12AB ray12hit16
427 12AB 67 ld h,a
427 12AC 2E 12 ld l,18
427 12AE E5 push hl
427 12AF C3 43 14 jp castray13
427 12B2 ;======================================================
427 12B2 castray12
427 12B2 0D dec c
427 12B3 CA 10 C5 jp z,raycast_end
427 12B6 AF xor a
427 12B7 62 ld h,d
427 12B8 6B ld l,e
427 12B9 24 inc h
427 12BA B6 or (hl)
427 12BB 20 85 jr nz,ray12hit1
427 12BD 2C inc l
427 12BE 24 inc h
427 12BF B6 or (hl)
427 12C0 20 87 jr nz,ray12hit2
427 12C2 2C inc l
427 12C3 24 inc h
427 12C4 B6 or (hl)
427 12C5 20 89 jr nz,ray12hit3
427 12C7 2C inc l
427 12C8 B6 or (hl)
427 12C9 20 8C jr nz,ray12hit4
427 12CB 2C inc l
427 12CC 24 inc h
427 12CD B6 or (hl)
427 12CE 20 8E jr nz,ray12hit5
427 12D0 2C inc l
427 12D1 24 inc h
427 12D2 B6 or (hl)
427 12D3 20 90 jr nz,ray12hit6
427 12D5 2C inc l
427 12D6 B6 or (hl)
427 12D7 20 93 jr nz,ray12hit7
427 12D9 2C inc l
427 12DA 24 inc h
427 12DB B6 or (hl)
427 12DC 20 95 jr nz,ray12hit8
427 12DE 2C inc l
427 12DF 24 inc h
427 12E0 B6 or (hl)
427 12E1 20 97 jr nz,ray12hit9
427 12E3 2C inc l
427 12E4 B6 or (hl)
427 12E5 20 9A jr nz,ray12hit10
427 12E7 2C inc l
427 12E8 24 inc h
427 12E9 B6 or (hl)
427 12EA 20 9C jr nz,ray12hit11
427 12EC 2C inc l
427 12ED 24 inc h
427 12EE B6 or (hl)
427 12EF 20 9E jr nz,ray12hit12
427 12F1 2C inc l
427 12F2 B6 or (hl)
427 12F3 20 A1 jr nz,ray12hit13
427 12F5 2C inc l
427 12F6 24 inc h
427 12F7 B6 or (hl)
427 12F8 20 A3 jr nz,ray12hit14
427 12FA 2C inc l
427 12FB 24 inc h
427 12FC B6 or (hl)
427 12FD 20 A5 jr nz,ray12hit15
427 12FF 2C inc l
427 1300 B6 or (hl)
427 1301 20 A8 jr nz,ray12hit16
427 1303 2C inc l
427 1304 24 inc h
427 1305 B6 or (hl)
427 1306 20 54 jr nz,ray12hit17
427 1308 2C inc l
427 1309 24 inc h
427 130A B6 or (hl)
427 130B 20 56 jr nz,ray12hit18
427 130D 2C inc l
427 130E B6 or (hl)
427 130F 20 59 jr nz,ray12hit19
427 1311 2C inc l
427 1312 24 inc h
427 1313 B6 or (hl)
427 1314 20 5B jr nz,ray12hit20
427 1316 2C inc l
427 1317 24 inc h
427 1318 B6 or (hl)
427 1319 20 5D jr nz,ray12hit21
427 131B 2C inc l
427 131C B6 or (hl)
427 131D 20 60 jr nz,ray12hit22
427 131F 2C inc l
427 1320 24 inc h
427 1321 B6 or (hl)
427 1322 20 62 jr nz,ray12hit23
427 1324 2C inc l
427 1325 24 inc h
427 1326 B6 or (hl)
427 1327 20 64 jr nz,ray12hit24
427 1329 2C inc l
427 132A B6 or (hl)
427 132B 20 67 jr nz,ray12hit25
427 132D 2C inc l
427 132E 24 inc h
427 132F B6 or (hl)
427 1330 20 69 jr nz,ray12hit26
427 1332 2C inc l
427 1333 24 inc h
427 1334 B6 or (hl)
427 1335 20 6B jr nz,ray12hit27
427 1337 2C inc l
427 1338 B6 or (hl)
427 1339 20 6E jr nz,ray12hit28
427 133B 2C inc l
427 133C 24 inc h
427 133D B6 or (hl)
427 133E 20 70 jr nz,ray12hit29
427 1340 2C inc l
427 1341 24 inc h
427 1342 B6 or (hl)
427 1343 20 72 jr nz,ray12hit30
427 1345 2C inc l
427 1346 B6 or (hl)
427 1347 20 75 jr nz,ray12hit31
427 1349 2C inc l
427 134A 24 inc h
427 134B B6 or (hl)
427 134C 20 77 jr nz,ray12hit32
427 134E 2C inc l
427 134F 24 inc h
427 1350 B6 or (hl)
427 1351 20 79 jr nz,ray12hit33
427 1353 2C inc l
427 1354 B6 or (hl)
427 1355 ray12hit34
427 1355 ; скорей всего луч никуда не попал
427 1355 67 ld h,a
427 1356 2E 28 ld l,40
427 1358 E5 push hl
427 1359 C3 43 14 jp castray13
427 135C ray12hit17
427 135C 67 ld h,a
427 135D 2E 14 ld l,20
427 135F E5 push hl
427 1360 C3 43 14 jp castray13
427 1363 ray12hit18
427 1363 67 ld h,a
427 1364 2E 15 ld l,21
427 1366 E5 push hl
427 1367 C3 43 14 jp castray13
427 136A ray12hit19
427 136A 67 ld h,a
427 136B 2E 16 ld l,22
427 136D E5 push hl
427 136E C3 43 14 jp castray13
427 1371 ray12hit20
427 1371 67 ld h,a
427 1372 2E 17 ld l,23
427 1374 E5 push hl
427 1375 C3 43 14 jp castray13
427 1378 ray12hit21
427 1378 67 ld h,a
427 1379 2E 19 ld l,25
427 137B E5 push hl
427 137C C3 43 14 jp castray13
427 137F ray12hit22
427 137F 67 ld h,a
427 1380 2E 19 ld l,25
427 1382 E5 push hl
427 1383 C3 43 14 jp castray13
427 1386 ray12hit23
427 1386 67 ld h,a
427 1387 2E 1B ld l,27
427 1389 E5 push hl
427 138A C3 43 14 jp castray13
427 138D ray12hit24
427 138D 67 ld h,a
427 138E 2E 1C ld l,28
427 1390 E5 push hl
427 1391 C3 43 14 jp castray13
427 1394 ray12hit25
427 1394 67 ld h,a
427 1395 2E 1D ld l,29
427 1397 E5 push hl
427 1398 C3 43 14 jp castray13
427 139B ray12hit26
427 139B 67 ld h,a
427 139C 2E 1E ld l,30
427 139E E5 push hl
427 139F C3 43 14 jp castray13
427 13A2 ray12hit27
427 13A2 67 ld h,a
427 13A3 2E 20 ld l,32
427 13A5 E5 push hl
427 13A6 C3 43 14 jp castray13
427 13A9 ray12hit28
427 13A9 67 ld h,a
427 13AA 2E 21 ld l,33
427 13AC E5 push hl
427 13AD C3 43 14 jp castray13
427 13B0 ray12hit29
427 13B0 67 ld h,a
427 13B1 2E 22 ld l,34
427 13B3 E5 push hl
427 13B4 C3 43 14 jp castray13
427 13B7 ray12hit30
427 13B7 67 ld h,a
427 13B8 2E 23 ld l,35
427 13BA E5 push hl
427 13BB C3 43 14 jp castray13
427 13BE ray12hit31
427 13BE 67 ld h,a
427 13BF 2E 24 ld l,36
427 13C1 E5 push hl
427 13C2 C3 43 14 jp castray13
427 13C5 ray12hit32
427 13C5 67 ld h,a
427 13C6 2E 26 ld l,38
427 13C8 E5 push hl
427 13C9 C3 43 14 jp castray13
427 13CC ray12hit33
427 13CC 67 ld h,a
427 13CD 2E 27 ld l,39
427 13CF E5 push hl
427 13D0 C3 43 14 jp castray13
427 13D3 ;======================================================
427 13D3 RAY_13_ROUTINE
427 13D3 ;======================================================
427 13D3 ray13hit1
427 13D3 67 ld h,a
427 13D4 2E 01 ld l,1
427 13D6 E5 push hl
427 13D7 C3 D8 15 jp castray14
427 13DA ray13hit2
427 13DA 67 ld h,a
427 13DB 2E 02 ld l,2
427 13DD E5 push hl
427 13DE C3 D8 15 jp castray14
427 13E1 ray13hit3
427 13E1 67 ld h,a
427 13E2 2E 04 ld l,4
427 13E4 E5 push hl
427 13E5 C3 D8 15 jp castray14
427 13E8 ray13hit4
427 13E8 67 ld h,a
427 13E9 2E 05 ld l,5
427 13EB E5 push hl
427 13EC C3 D8 15 jp castray14
427 13EF ray13hit5
427 13EF 67 ld h,a
427 13F0 2E 06 ld l,6
427 13F2 E5 push hl
427 13F3 C3 D8 15 jp castray14
427 13F6 ray13hit6
427 13F6 67 ld h,a
427 13F7 2E 07 ld l,7
427 13F9 E5 push hl
427 13FA C3 D8 15 jp castray14
427 13FD ray13hit7
427 13FD 67 ld h,a
427 13FE 2E 09 ld l,9
427 1400 E5 push hl
427 1401 C3 D8 15 jp castray14
427 1404 ray13hit8
427 1404 67 ld h,a
427 1405 2E 0A ld l,10
427 1407 E5 push hl
427 1408 C3 D8 15 jp castray14
427 140B ray13hit9
427 140B 67 ld h,a
427 140C 2E 0B ld l,11
427 140E E5 push hl
427 140F C3 D8 15 jp castray14
427 1412 ray13hit10
427 1412 67 ld h,a
427 1413 2E 0C ld l,12
427 1415 E5 push hl
427 1416 C3 D8 15 jp castray14
427 1419 ray13hit11
427 1419 67 ld h,a
427 141A 2E 0E ld l,14
427 141C E5 push hl
427 141D C3 D8 15 jp castray14
427 1420 ray13hit12
427 1420 67 ld h,a
427 1421 2E 0F ld l,15
427 1423 E5 push hl
427 1424 C3 D8 15 jp castray14
427 1427 ray13hit13
427 1427 67 ld h,a
427 1428 2E 10 ld l,16
427 142A E5 push hl
427 142B C3 D8 15 jp castray14
427 142E ray13hit14
427 142E 67 ld h,a
427 142F 2E 11 ld l,17
427 1431 E5 push hl
427 1432 C3 D8 15 jp castray14
427 1435 ray13hit15
427 1435 67 ld h,a
427 1436 2E 13 ld l,19
427 1438 E5 push hl
427 1439 C3 D8 15 jp castray14
427 143C ray13hit16
427 143C 67 ld h,a
427 143D 2E 14 ld l,20
427 143F E5 push hl
427 1440 C3 D8 15 jp castray14
427 1443 ;======================================================
427 1443 castray13
427 1443 0D dec c
427 1444 CA 10 C5 jp z,raycast_end
427 1447 AF xor a
427 1448 62 ld h,d
427 1449 6B ld l,e
427 144A 2C inc l
427 144B 24 inc h
427 144C B6 or (hl)
427 144D 20 84 jr nz,ray13hit1
427 144F 2C inc l
427 1450 24 inc h
427 1451 B6 or (hl)
427 1452 20 86 jr nz,ray13hit2
427 1454 2C inc l
427 1455 24 inc h
427 1456 B6 or (hl)
427 1457 20 88 jr nz,ray13hit3
427 1459 2C inc l
427 145A B6 or (hl)
427 145B 20 8B jr nz,ray13hit4
427 145D 2C inc l
427 145E 24 inc h
427 145F B6 or (hl)
427 1460 20 8D jr nz,ray13hit5
427 1462 2C inc l
427 1463 24 inc h
427 1464 B6 or (hl)
427 1465 20 8F jr nz,ray13hit6
427 1467 2C inc l
427 1468 24 inc h
427 1469 B6 or (hl)
427 146A 20 91 jr nz,ray13hit7
427 146C 2C inc l
427 146D B6 or (hl)
427 146E 20 94 jr nz,ray13hit8
427 1470 2C inc l
427 1471 24 inc h
427 1472 B6 or (hl)
427 1473 20 96 jr nz,ray13hit9
427 1475 2C inc l
427 1476 24 inc h
427 1477 B6 or (hl)
427 1478 20 98 jr nz,ray13hit10
427 147A 2C inc l
427 147B 24 inc h
427 147C B6 or (hl)
427 147D 20 9A jr nz,ray13hit11
427 147F 2C inc l
427 1480 B6 or (hl)
427 1481 20 9D jr nz,ray13hit12
427 1483 2C inc l
427 1484 24 inc h
427 1485 B6 or (hl)
427 1486 20 9F jr nz,ray13hit13
427 1488 2C inc l
427 1489 24 inc h
427 148A B6 or (hl)
427 148B 20 A1 jr nz,ray13hit14
427 148D 2C inc l
427 148E 24 inc h
427 148F B6 or (hl)
427 1490 20 A3 jr nz,ray13hit15
427 1492 2C inc l
427 1493 B6 or (hl)
427 1494 20 A6 jr nz,ray13hit16
427 1496 2C inc l
427 1497 24 inc h
427 1498 B6 or (hl)
427 1499 20 56 jr nz,ray13hit17
427 149B 2C inc l
427 149C 24 inc h
427 149D B6 or (hl)
427 149E 20 58 jr nz,ray13hit18
427 14A0 2C inc l
427 14A1 24 inc h
427 14A2 B6 or (hl)
427 14A3 20 5A jr nz,ray13hit19
427 14A5 2C inc l
427 14A6 B6 or (hl)
427 14A7 20 5D jr nz,ray13hit20
427 14A9 2C inc l
427 14AA 24 inc h
427 14AB B6 or (hl)
427 14AC 20 5F jr nz,ray13hit21
427 14AE 2C inc l
427 14AF 24 inc h
427 14B0 B6 or (hl)
427 14B1 20 61 jr nz,ray13hit22
427 14B3 2C inc l
427 14B4 24 inc h
427 14B5 B6 or (hl)
427 14B6 20 63 jr nz,ray13hit23
427 14B8 2C inc l
427 14B9 B6 or (hl)
427 14BA 20 66 jr nz,ray13hit24
427 14BC 2C inc l
427 14BD 24 inc h
427 14BE B6 or (hl)
427 14BF 20 68 jr nz,ray13hit25
427 14C1 2C inc l
427 14C2 24 inc h
427 14C3 B6 or (hl)
427 14C4 20 6A jr nz,ray13hit26
427 14C6 2C inc l
427 14C7 24 inc h
427 14C8 B6 or (hl)
427 14C9 20 6C jr nz,ray13hit27
427 14CB 2C inc l
427 14CC B6 or (hl)
427 14CD 20 6F jr nz,ray13hit28
427 14CF 2C inc l
427 14D0 24 inc h
427 14D1 B6 or (hl)
427 14D2 20 71 jr nz,ray13hit29
427 14D4 2C inc l
427 14D5 24 inc h
427 14D6 B6 or (hl)
427 14D7 20 73 jr nz,ray13hit30
427 14D9 2C inc l
427 14DA B6 or (hl)
427 14DB 20 76 jr nz,ray13hit31
427 14DD 2C inc l
427 14DE 24 inc h
427 14DF B6 or (hl)
427 14E0 20 78 jr nz,ray13hit32
427 14E2 2C inc l
427 14E3 24 inc h
427 14E4 B6 or (hl)
427 14E5 20 7A jr nz,ray13hit33
427 14E7 2C inc l
427 14E8 24 inc h
427 14E9 B6 or (hl)
427 14EA ray13hit34
427 14EA ; скорей всего луч никуда не попал
427 14EA 67 ld h,a
427 14EB 2E 2A ld l,42
427 14ED E5 push hl
427 14EE C3 D8 15 jp castray14
427 14F1 ray13hit17
427 14F1 67 ld h,a
427 14F2 2E 15 ld l,21
427 14F4 E5 push hl
427 14F5 C3 D8 15 jp castray14
427 14F8 ray13hit18
427 14F8 67 ld h,a
427 14F9 2E 16 ld l,22
427 14FB E5 push hl
427 14FC C3 D8 15 jp castray14
427 14FF ray13hit19
427 14FF 67 ld h,a
427 1500 2E 18 ld l,24
427 1502 E5 push hl
427 1503 C3 D8 15 jp castray14
427 1506 ray13hit20
427 1506 67 ld h,a
427 1507 2E 19 ld l,25
427 1509 E5 push hl
427 150A C3 D8 15 jp castray14
427 150D ray13hit21
427 150D 67 ld h,a
427 150E 2E 1A ld l,26
427 1510 E5 push hl
427 1511 C3 D8 15 jp castray14
427 1514 ray13hit22
427 1514 67 ld h,a
427 1515 2E 1B ld l,27
427 1517 E5 push hl
427 1518 C3 D8 15 jp castray14
427 151B ray13hit23
427 151B 67 ld h,a
427 151C 2E 1D ld l,29
427 151E E5 push hl
427 151F C3 D8 15 jp castray14
427 1522 ray13hit24
427 1522 67 ld h,a
427 1523 2E 1E ld l,30
427 1525 E5 push hl
427 1526 C3 D8 15 jp castray14
427 1529 ray13hit25
427 1529 67 ld h,a
427 152A 2E 1F ld l,31
427 152C E5 push hl
427 152D C3 D8 15 jp castray14
427 1530 ray13hit26
427 1530 67 ld h,a
427 1531 2E 20 ld l,32
427 1533 E5 push hl
427 1534 C3 D8 15 jp castray14
427 1537 ray13hit27
427 1537 67 ld h,a
427 1538 2E 22 ld l,34
427 153A E5 push hl
427 153B C3 D8 15 jp castray14
427 153E ray13hit28
427 153E 67 ld h,a
427 153F 2E 23 ld l,35
427 1541 E5 push hl
427 1542 C3 D8 15 jp castray14
427 1545 ray13hit29
427 1545 67 ld h,a
427 1546 2E 24 ld l,36
427 1548 E5 push hl
427 1549 C3 D8 15 jp castray14
427 154C ray13hit30
427 154C 67 ld h,a
427 154D 2E 25 ld l,37
427 154F E5 push hl
427 1550 C3 D8 15 jp castray14
427 1553 ray13hit31
427 1553 67 ld h,a
427 1554 2E 26 ld l,38
427 1556 E5 push hl
427 1557 C3 D8 15 jp castray14
427 155A ray13hit32
427 155A 67 ld h,a
427 155B 2E 28 ld l,40
427 155D E5 push hl
427 155E C3 D8 15 jp castray14
427 1561 ray13hit33
427 1561 67 ld h,a
427 1562 2E 29 ld l,41
427 1564 E5 push hl
427 1565 C3 D8 15 jp castray14
427 1568 ;======================================================
427 1568 RAY_14_ROUTINE
427 1568 ;======================================================
427 1568 ray14hit1
427 1568 67 ld h,a
427 1569 2E 01 ld l,1
427 156B E5 push hl
427 156C C3 6F 17 jp castray15
427 156F ray14hit2
427 156F 67 ld h,a
427 1570 2E 02 ld l,2
427 1572 E5 push hl
427 1573 C3 6F 17 jp castray15
427 1576 ray14hit3
427 1576 67 ld h,a
427 1577 2E 04 ld l,4
427 1579 E5 push hl
427 157A C3 6F 17 jp castray15
427 157D ray14hit4
427 157D 67 ld h,a
427 157E 2E 05 ld l,5
427 1580 E5 push hl
427 1581 C3 6F 17 jp castray15
427 1584 ray14hit5
427 1584 67 ld h,a
427 1585 2E 07 ld l,7
427 1587 E5 push hl
427 1588 C3 6F 17 jp castray15
427 158B ray14hit6
427 158B 67 ld h,a
427 158C 2E 07 ld l,7
427 158E E5 push hl
427 158F C3 6F 17 jp castray15
427 1592 ray14hit7
427 1592 67 ld h,a
427 1593 2E 09 ld l,9
427 1595 E5 push hl
427 1596 C3 6F 17 jp castray15
427 1599 ray14hit8
427 1599 67 ld h,a
427 159A 2E 0A ld l,10
427 159C E5 push hl
427 159D C3 6F 17 jp castray15
427 15A0 ray14hit9
427 15A0 67 ld h,a
427 15A1 2E 0C ld l,12
427 15A3 E5 push hl
427 15A4 C3 6F 17 jp castray15
427 15A7 ray14hit10
427 15A7 67 ld h,a
427 15A8 2E 0D ld l,13
427 15AA E5 push hl
427 15AB C3 6F 17 jp castray15
427 15AE ray14hit11
427 15AE 67 ld h,a
427 15AF 2E 0E ld l,14
427 15B1 E5 push hl
427 15B2 C3 6F 17 jp castray15
427 15B5 ray14hit12
427 15B5 67 ld h,a
427 15B6 2E 0F ld l,15
427 15B8 E5 push hl
427 15B9 C3 6F 17 jp castray15
427 15BC ray14hit13
427 15BC 67 ld h,a
427 15BD 2E 11 ld l,17
427 15BF E5 push hl
427 15C0 C3 6F 17 jp castray15
427 15C3 ray14hit14
427 15C3 67 ld h,a
427 15C4 2E 12 ld l,18
427 15C6 E5 push hl
427 15C7 C3 6F 17 jp castray15
427 15CA ray14hit15
427 15CA 67 ld h,a
427 15CB 2E 13 ld l,19
427 15CD E5 push hl
427 15CE C3 6F 17 jp castray15
427 15D1 ray14hit16
427 15D1 67 ld h,a
427 15D2 2E 15 ld l,21
427 15D4 E5 push hl
427 15D5 C3 6F 17 jp castray15
427 15D8 ;======================================================
427 15D8 castray14
427 15D8 0D dec c
427 15D9 CA 10 C5 jp z,raycast_end
427 15DC AF xor a
427 15DD 62 ld h,d
427 15DE 6B ld l,e
427 15DF 2C inc l
427 15E0 24 inc h
427 15E1 B6 or (hl)
427 15E2 20 84 jr nz,ray14hit1
427 15E4 2C inc l
427 15E5 24 inc h
427 15E6 B6 or (hl)
427 15E7 20 86 jr nz,ray14hit2
427 15E9 2C inc l
427 15EA 24 inc h
427 15EB B6 or (hl)
427 15EC 20 88 jr nz,ray14hit3
427 15EE 2C inc l
427 15EF 24 inc h
427 15F0 B6 or (hl)
427 15F1 20 8A jr nz,ray14hit4
427 15F3 2C inc l
427 15F4 24 inc h
427 15F5 B6 or (hl)
427 15F6 20 8C jr nz,ray14hit5
427 15F8 2C inc l
427 15F9 B6 or (hl)
427 15FA 20 8F jr nz,ray14hit6
427 15FC 2C inc l
427 15FD 24 inc h
427 15FE B6 or (hl)
427 15FF 20 91 jr nz,ray14hit7
427 1601 2C inc l
427 1602 24 inc h
427 1603 B6 or (hl)
427 1604 20 93 jr nz,ray14hit8
427 1606 2C inc l
427 1607 24 inc h
427 1608 B6 or (hl)
427 1609 20 95 jr nz,ray14hit9
427 160B 2C inc l
427 160C 24 inc h
427 160D B6 or (hl)
427 160E 20 97 jr nz,ray14hit10
427 1610 2C inc l
427 1611 24 inc h
427 1612 B6 or (hl)
427 1613 20 99 jr nz,ray14hit11
427 1615 2C inc l
427 1616 B6 or (hl)
427 1617 20 9C jr nz,ray14hit12
427 1619 2C inc l
427 161A 24 inc h
427 161B B6 or (hl)
427 161C 20 9E jr nz,ray14hit13
427 161E 2C inc l
427 161F 24 inc h
427 1620 B6 or (hl)
427 1621 20 A0 jr nz,ray14hit14
427 1623 2C inc l
427 1624 24 inc h
427 1625 B6 or (hl)
427 1626 20 A2 jr nz,ray14hit15
427 1628 2C inc l
427 1629 24 inc h
427 162A B6 or (hl)
427 162B 20 A4 jr nz,ray14hit16
427 162D 2C inc l
427 162E B6 or (hl)
427 162F 20 57 jr nz,ray14hit17
427 1631 2C inc l
427 1632 24 inc h
427 1633 B6 or (hl)
427 1634 20 59 jr nz,ray14hit18
427 1636 2C inc l
427 1637 24 inc h
427 1638 B6 or (hl)
427 1639 20 5B jr nz,ray14hit19
427 163B 2C inc l
427 163C 24 inc h
427 163D B6 or (hl)
427 163E 20 5D jr nz,ray14hit20
427 1640 2C inc l
427 1641 24 inc h
427 1642 B6 or (hl)
427 1643 20 5F jr nz,ray14hit21
427 1645 2C inc l
427 1646 24 inc h
427 1647 B6 or (hl)
427 1648 20 61 jr nz,ray14hit22
427 164A 2C inc l
427 164B B6 or (hl)
427 164C 20 64 jr nz,ray14hit23
427 164E 2C inc l
427 164F 24 inc h
427 1650 B6 or (hl)
427 1651 20 66 jr nz,ray14hit24
427 1653 2C inc l
427 1654 24 inc h
427 1655 B6 or (hl)
427 1656 20 68 jr nz,ray14hit25
427 1658 2C inc l
427 1659 24 inc h
427 165A B6 or (hl)
427 165B 20 6A jr nz,ray14hit26
427 165D 2C inc l
427 165E 24 inc h
427 165F B6 or (hl)
427 1660 20 6C jr nz,ray14hit27
427 1662 2C inc l
427 1663 B6 or (hl)
427 1664 20 6F jr nz,ray14hit28
427 1666 2C inc l
427 1667 24 inc h
427 1668 B6 or (hl)
427 1669 20 71 jr nz,ray14hit29
427 166B 2C inc l
427 166C 24 inc h
427 166D B6 or (hl)
427 166E 20 73 jr nz,ray14hit30
427 1670 2C inc l
427 1671 24 inc h
427 1672 B6 or (hl)
427 1673 20 75 jr nz,ray14hit31
427 1675 2C inc l
427 1676 24 inc h
427 1677 B6 or (hl)
427 1678 20 77 jr nz,ray14hit32
427 167A 2C inc l
427 167B 24 inc h
427 167C B6 or (hl)
427 167D 20 79 jr nz,ray14hit33
427 167F 2C inc l
427 1680 B6 or (hl)
427 1681 ray14hit34
427 1681 ; скорей всего луч никуда не попал
427 1681 67 ld h,a
427 1682 2E 2C ld l,44
427 1684 E5 push hl
427 1685 C3 6F 17 jp castray15
427 1688 ray14hit17
427 1688 67 ld h,a
427 1689 2E 16 ld l,22
427 168B E5 push hl
427 168C C3 6F 17 jp castray15
427 168F ray14hit18
427 168F 67 ld h,a
427 1690 2E 17 ld l,23
427 1692 E5 push hl
427 1693 C3 6F 17 jp castray15
427 1696 ray14hit19
427 1696 67 ld h,a
427 1697 2E 18 ld l,24
427 1699 E5 push hl
427 169A C3 6F 17 jp castray15
427 169D ray14hit20
427 169D 67 ld h,a
427 169E 2E 1A ld l,26
427 16A0 E5 push hl
427 16A1 C3 6F 17 jp castray15
427 16A4 ray14hit21
427 16A4 67 ld h,a
427 16A5 2E 1B ld l,27
427 16A7 E5 push hl
427 16A8 C3 6F 17 jp castray15
427 16AB ray14hit22
427 16AB 67 ld h,a
427 16AC 2E 1D ld l,29
427 16AE E5 push hl
427 16AF C3 6F 17 jp castray15
427 16B2 ray14hit23
427 16B2 67 ld h,a
427 16B3 2E 1D ld l,29
427 16B5 E5 push hl
427 16B6 C3 6F 17 jp castray15
427 16B9 ray14hit24
427 16B9 67 ld h,a
427 16BA 2E 1F ld l,31
427 16BC E5 push hl
427 16BD C3 6F 17 jp castray15
427 16C0 ray14hit25
427 16C0 67 ld h,a
427 16C1 2E 20 ld l,32
427 16C3 E5 push hl
427 16C4 C3 6F 17 jp castray15
427 16C7 ray14hit26
427 16C7 67 ld h,a
427 16C8 2E 22 ld l,34
427 16CA E5 push hl
427 16CB C3 6F 17 jp castray15
427 16CE ray14hit27
427 16CE 67 ld h,a
427 16CF 2E 23 ld l,35
427 16D1 E5 push hl
427 16D2 C3 6F 17 jp castray15
427 16D5 ray14hit28
427 16D5 67 ld h,a
427 16D6 2E 24 ld l,36
427 16D8 E5 push hl
427 16D9 C3 6F 17 jp castray15
427 16DC ray14hit29
427 16DC 67 ld h,a
427 16DD 2E 25 ld l,37
427 16DF E5 push hl
427 16E0 C3 6F 17 jp castray15
427 16E3 ray14hit30
427 16E3 67 ld h,a
427 16E4 2E 27 ld l,39
427 16E6 E5 push hl
427 16E7 C3 6F 17 jp castray15
427 16EA ray14hit31
427 16EA 67 ld h,a
427 16EB 2E 28 ld l,40
427 16ED E5 push hl
427 16EE C3 6F 17 jp castray15
427 16F1 ray14hit32
427 16F1 67 ld h,a
427 16F2 2E 29 ld l,41
427 16F4 E5 push hl
427 16F5 C3 6F 17 jp castray15
427 16F8 ray14hit33
427 16F8 67 ld h,a
427 16F9 2E 2B ld l,43
427 16FB E5 push hl
427 16FC C3 6F 17 jp castray15
3Ы: Кто напишет быстрее? :v2_dizzy_vodka2:
https://github.com/z00m128/sjasmplus...es/tag/v1.13.1
Changelog:
v1.13.1:
- added --syntax command line option
- added OPT directive (modifies some command line options)
- added way to use structure at designed address
- MACRO can be now named through label (optional syntax)
- added DEFARRAY+ directive (for splitting long list of DEFARRAY values)
- added CSPECTMAP directive for MAP files for CSpect emulator
- added support for SJASMPLUSOPTS environment variable
- Z80N new variants of syntax, now also "mul de : mul : pixelad hl : pixeldn hl" works
- minor bugfixes, improvements and internal refactorings (error reporting)
- updated syntax-highlight file for KDE5 editors (Kate)
Documentation http://z00m128.github.io/sjasmplus/documentation.html (or in the package/cloned source).
inc hl ; hl = hl + 1
И что єто даст?
ничего
inc h инкримент позиции по вертикали
inc l инкримент позиции по горизонтали
чередованием их и происходит пуляние луча под разными углами
так же для других углов там dec h и dec l
inc hl даст только инкримент по горизонтали и все
- - - Добавлено - - -
ну да они там не просто так
- - - Добавлено - - -
Код:1110 5DF7 castray1
1110 5DF7 62 ld h,d
1110 5DF8 6B ld l,e
1110 5DF9 AF xor a
1110 5DFA ED 4F ld r,a
1110 5DFC 2C inc l
1110 5DFD 24 inc h
1110 5DFE B6 or (hl)
1110 5DFF 20 63 jr nz,ray1hit
1110 5E01 2C inc l
1110 5E02 B6 or (hl)
1110 5E03 20 5F jr nz,ray1hit
1110 5E05 2C inc l
1110 5E06 B6 or (hl)
1110 5E07 20 5B jr nz,ray1hit
1110 5E09 2C inc l
1110 5E0A B6 or (hl)
1110 5E0B 20 57 jr nz,ray1hit
1110 5E0D 2C inc l
1110 5E0E B6 or (hl)
1110 5E0F 20 53 jr nz,ray1hit
1110 5E11 2C inc l
1110 5E12 B6 or (hl)
1110 5E13 20 4F jr nz,ray1hit
1110 5E15 2C inc l
1110 5E16 B6 or (hl)
1110 5E17 20 4B jr nz,ray1hit
1110 5E19 2C inc l
1110 5E1A B6 or (hl)
1110 5E1B 20 47 jr nz,ray1hit
1110 5E1D 2C inc l
1110 5E1E B6 or (hl)
1110 5E1F 20 43 jr nz,ray1hit
1110 5E21 2C inc l
Код:1110 7D3F castray56
1110 7D3F 62 ld h,d
1110 7D40 6B ld l,e
1110 7D41 AF xor a
1110 7D42 ED 4F ld r,a
1110 7D44 2D dec l
1110 7D45 24 inc h
1110 7D46 B6 or (hl)
1110 7D47 20 6C jr nz,ray56hit
1110 7D49 2D dec l
1110 7D4A B6 or (hl)
1110 7D4B 20 68 jr nz,ray56hit
1110 7D4D 2D dec l
1110 7D4E 24 inc h
1110 7D4F B6 or (hl)
1110 7D50 20 63 jr nz,ray56hit
1110 7D52 2D dec l
1110 7D53 B6 or (hl)
1110 7D54 20 5F jr nz,ray56hit
1110 7D56 2D dec l
1110 7D57 24 inc h
1110 7D58 B6 or (hl)
1110 7D59 20 5A jr nz,ray56hit
1110 7D5B 2D dec l
1110 7D5C B6 or (hl)
- - - Добавлено - - -Код:1110 97FC castray104
1110 97FC 62 ld h,d
1110 97FD 6B ld l,e
1110 97FE AF xor a
1110 97FF ED 4F ld r,a
1110 9801 25 dec h
1110 9802 B6 or (hl)
1110 9803 20 6D jr nz,ray104hit
1110 9805 2C inc l
1110 9806 25 dec h
1110 9807 B6 or (hl)
1110 9808 20 68 jr nz,ray104hit
1110 980A 25 dec h
1110 980B B6 or (hl)
1110 980C 20 64 jr nz,ray104hit
1110 980E 2C inc l
1110 980F 25 dec h
1110 9810 B6 or (hl)
1110 9811 20 5F jr nz,ray104hit
1110 9813 25 dec h
1110 9814 B6 or (hl)
1110 9815 20 5B jr nz,ray104hit
1110 9817 25 dec h
1110 9818 B6 or (hl)
1110 9819 20 57 jr nz,ray104hit
1110 981B 2C inc l
1110 981C 25 dec h
1110 981D B6 or (hl)
1110 981E 20 52 jr nz,ray104hit
1110 9820 25 dec h
1110 9821 B6 or (hl)
1110 9822 20 4E jr nz,ray104hit
1110 9824 2C inc l
1110 9825 25 dec h
1110 9826 B6 or (hl)
1110 9827 20 49 jr nz,ray104hit
1110 9829 25 dec h
1110 982A B6 or (hl)
1110 982B 20 45 jr nz,ray104hit
1110 982D 25 dec h
1110 982E B6 or (hl)
1110 982F 20 41 jr nz,ray104hit
1110 9831 2C inc l
1110 9832 25 dec h
там же вроде текстуры на стенах
а я себе такого позволит не могу
у меня только красивые стобцы с отражениями и полупрозрачностями
из которых толком ничего нельзя построить тк сильно крупные
I surely wouldn't want to write such code manually.
I think I will try to show some sjasmplus MACRO version of such code generator in couple of days, if I will be in mood for it (should be simple to do).
If you mean like performance-faster, you can for example squeeze few more percent boost % by sharing the early ray paths between, for your short example the ray13 and ray14 share first three tiles of map, so the ray13hit1-3 code paths can be merged with ray14hit1-3 (pushing two values on stack) and jump to ray15.
But this will make the code generator even more complex (to the extend where I would NOT want to write it in sjasmplus .. it may be still possible, but doesn't sound as simple as your current example... so I would probably use rather C++ for this one, as I feel most familiar with it).
And for rays very close to (+0,+-1) vector maybe there's some trick how to use cpi/cpd/cpir/cpdr, but I'm afraid there's maybe just two rays going precisely in +-1 delta which would MAYBE benefit of such change.
And finally, for particular size of map/screen/ray-count it may be faster to inverse the whole thing, going through MxN map and for every non-zero tile to update minimal distance for all rays going through the tile (of course everything lookup-table-based, i.e. again heavy memory usage and needs code-generator too), after the MxN map scan you would end with ray_array containing all the minimal distances for all rays. I didn't do the math myself, if this approach is faster for some sizes which make actual visual sense, but I'm pretty sure it's faster for some combinations (although maybe the size combinations which make visual sense are always better with classic ray-cast like you have, so this is just bare "idea", nothing more).
And of course as long as we are talking about Wolf3D, the DOOM BSP was far superior to it (in performance). Although the Z80 doesn't have MUL and DIV, and the amount of rays is probably minimal, if you have at least 100+ horizontal resolution (ray count), I guess even Z80 would do 2D BSP faster than raycasting.
Raycasting can produce interesting results if you have hi-res map (i.e. voxel-like), but in case of Wolf3D like maps (big squares only), the DOOM line-segment approach allows not only for better performance, but also for more complex maps. But it's lot more work the DOOM thing, and again Speccy introduces few more constraints (memory) which would make it difficult to exploit... I personally prefer to leave these things to 32+ bit CPUs, although I can appreciate the achievement of making the Z80 variants of them, but I don't find them truly practical (like I would WANT to play doom-like game on ZX in 4-10 FPS ... nope).
конечно кеширование уже проверенных клеток могло бы и правда ускорить процесс
но как его организовать?
старт сканирования может начатся с любого угла
то есть понадобится еще в 2 3 раза больше памяти под дополнительный код
да и написать генератор процедуры будет гораздо сложнее
так тоже сожрет много памяти
Код:ray3hit2
ld h,a
ld l,2
push hl
dec c
jp z,raycast_end
push hl
dec c
jp z,raycast_end
push hl
dec c
jp z,raycast_end
push hl
jp castray6
чуть экономичней
- - - Добавлено - - -Код:ray3hit2
ld h,a
ld l,2
push hl
call save3
jp castray6
save3
dec c
jp z,raycast_end
push hl
dec c
jp z,raycast_end
push hl
dec c
jp z,raycast_end
push hl
ret
наверно ray15-16hit3 :)Цитата:
ray14hit1-3
About start at any ray... you can still have ray14hit1-3 as it was (or merged with r15-16), but then the problem is when for example ray13 ends the range, it will push extra 3 values... although that doesn't sound *that* bad, if you are ready for such overflow and can recover from it. And you need to put "end" to every ray14-ray16 entry as you don't know where it will end. Oh wait, you are doing "dec c" as column counter? You can maybe get some boost from this to, keeping all rays calling next-other, and just modify/restore the start of ending-ray code with `jp raycast_end` and not doing `dec c + jp z,` test for every ray.
The shared tiles on average will very likely boost the overall performance even if they put 2-4 values extra on stack - but that's a boost in case when you are already very near the tile, which are generally very fast anyway. :D ... so again, while technically it is faster than your original example, it's more like joke-teasing you a bit, not really practical or bringing some major boost. The self-modify terminating jump may be actual real boost, even making C free for different use. (but then the tile-sharing hit code will definitely put more values onto stack, as it doesn't count columns then).
If for example every raycast code starts `ld hl,de : xor a`, you can put the "raycast_end" at 0xAF6B and just alternate the `ld h,d` to `jp $nnnn` and back... to create "render terminators".
- - - Updated - - -
you can't `CALL + RET` while doing `PUSH hl` filler ;) the triple code must be there.. although if the value pushed is the same for all shared-rays, the hit3 can contain full fill, and hit1/2 will use it as "tail" optimization jumping into it after setting HL to desired value.
да это не даст большего выигрыша
~500t +512байт памяти
в принципе можно сделать
- - - Добавлено - - -
+сам установщик jp raycast_end
займет много памяти
тк будет нужна таблица адресов куда его можно вставить
- - - Добавлено - - -
да и тогда легко возможна такая ситуация
casttay1
ray1hit5
push hl
push hl
push hl
jp castray7
castray2
jp raycast_end ;skiped o_O
а далее стек уничтожает все на своем пути :)
Ага в принципе придумал как написать проверку схожести первых шагов в Lua
Потом как нибудь напишу
наверное выигрыш по скорости будет ощутимым
NEO SPECTRUMAN, так а где сама игрушка/демка то с рейкастом?
нету и долго не будет
старую версию под 128к с измерителем расстояния на регистре R
я пару раз уже вбрасывал
новая еще не в запускаемом состоянии
(я только недавно разобрал свой старый сорец и переписал под получение готовых значений расстояния вместо высчитывания)
да и я не спешу ее делать
и будет она под 16с пентевы наверно
+только что придумал как сделать еще немного плавней
- - - Добавлено - - -
В старой версии был такой рейкастер
и несколько коррекций искажений
в итоге было много артефактов
и использовать полученный движок было нельзя
да и сама концепция такого рейкастера подразумевает много артефактов
мало того там я еще пытался сделать сглаживатель\улучшатель полученной картини
но это сожрало всю память...
...а качество толком не улучшилось
- - - Добавлено - - -Код:1114 696A castray21
1114 696A 62 ld h,d
1114 696B 6B ld l,e
1114 696C AF xor a
1114 696D ED 4F ld r,a
1114 696F 24 inc h
1114 6970 B6 or (hl)
1114 6971 20 71 jr nz,ray21hit
1114 6973 2C inc l
1114 6974 24 inc h
1114 6975 B6 or (hl)
1114 6976 20 6C jr nz,ray21hit
1114 6978 24 inc h
1114 6979 B6 or (hl)
1114 697A 20 68 jr nz,ray21hit
1114 697C 2C inc l
1114 697D 24 inc h
1114 697E B6 or (hl)
1114 697F 20 63 jr nz,ray21hit
1114 6981 24 inc h
1114 6982 B6 or (hl)
1114 6983 20 5F jr nz,ray21hit
1114 6985 2C inc l
1114 6986 24 inc h
1114 6987 B6 or (hl)
1114 6988 20 5A jr nz,ray21hit
1114 698A 2C inc l
1114 698B 24 inc h
1114 698C B6 or (hl)
1114 698D 20 55 jr nz,ray21hit
1114 698F 24 inc h
1114 6990 B6 or (hl)
1114 6991 20 51 jr nz,ray21hit
1114 6993 2C inc l
1114 6994 24 inc h
1114 6995 B6 or (hl)
1114 6996 20 4C jr nz,ray21hit
1114 6998 24 inc h
1114 6999 B6 or (hl)
1114 699A 20 48 jr nz,ray21hit
1114 699C 2C inc l
1114 699D 24 inc h
1114 699E B6 or (hl)
1114 699F 20 43 jr nz,ray21hit
1114 69A1 2C inc l
1114 69A2 24 inc h
1114 69A3 B6 or (hl)
1114 69A4 20 3E jr nz,ray21hit
1114 69A6 24 inc h
1114 69A7 B6 or (hl)
1114 69A8 20 3A jr nz,ray21hit
1114 69AA 2C inc l
1114 69AB 24 inc h
1114 69AC B6 or (hl)
1114 69AD 20 35 jr nz,ray21hit
1114 69AF 24 inc h
1114 69B0 B6 or (hl)
1114 69B1 20 31 jr nz,ray21hit
1114 69B3 2C inc l
1114 69B4 24 inc h
1114 69B5 B6 or (hl)
1114 69B6 20 2C jr nz,ray21hit
1114 69B8 2C inc l
1114 69B9 24 inc h
1114 69BA B6 or (hl)
1114 69BB 20 27 jr nz,ray21hit
1114 69BD 24 inc h
1114 69BE B6 or (hl)
1114 69BF 20 23 jr nz,ray21hit
1114 69C1 2C inc l
1114 69C2 24 inc h
1114 69C3 B6 or (hl)
1114 69C4 20 1E jr nz,ray21hit
1114 69C6 24 inc h
1114 69C7 B6 or (hl)
1114 69C8 20 1A jr nz,ray21hit
1114 69CA 2C inc l
1114 69CB 24 inc h
1114 69CC B6 or (hl)
1114 69CD 20 15 jr nz,ray21hit
1114 69CF 2C inc l
1114 69D0 24 inc h
1114 69D1 B6 or (hl)
1114 69D2 20 10 jr nz,ray21hit
1114 69D4 24 inc h
1114 69D5 B6 or (hl)
1114 69D6 20 0C jr nz,ray21hit
1114 69D8 2C inc l
1114 69D9 24 inc h
1114 69DA B6 or (hl)
1114 69DB 20 07 jr nz,ray21hit
1114 69DD 24 inc h
1114 69DE B6 or (hl)
1114 69DF 20 03 jr nz,ray21hit
1114 69E1 2C inc l
1114 69E2 24 inc h
1114 69E3 B6 or (hl)
1114 69E4 ray21hit
1114 69E4 67 ld h,a
1114 69E5 ED 5F ld a,r
1114 69E7 6F ld l,a
1114 69E8 CB 3D srl l
1114 69EA CB 3D srl l
1114 69EC CB 3D srl l
1114 69EE CB 3D srl l
1114 69F0 CB 3D srl l
1114 69F2 CB 3D srl l
1114 69F4 95 sub l
1114 69F5 CB 3D srl l
1114 69F7 95 sub l
1114 69F8 CB 3D srl l
1114 69FA 95 sub l
1114 69FB 6F ld l,a
1114 69FC E5 push hl
1114 69FD 0D dec c
1114 69FE CA A5 A5 jp z,raycast_end
1114 6A01 castray22
1114 6A01 62 ld h,d
1114 6A02 6B ld l,e
1114 6A03 AF xor a
1114 6A04 ED 4F ld r,a
1114 6A06 24 inc h
1114 6A07 B6 or (hl)
1114 6A08 20 6F jr nz,ray22hit
1114 6A0A 2C inc l
1114 6A0B 24 inc h
1114 6A0C B6 or (hl)
1114 6A0D 20 6A jr nz,ray22hit
1114 6A0F 24 inc h
1114 6A10 B6 or (hl)
1114 6A11 20 66 jr nz,ray22hit
1114 6A13 2C inc l
1114 6A14 24 inc h
1114 6A15 B6 or (hl)
1114 6A16 20 61 jr nz,ray22hit
1114 6A18 24 inc h
1114 6A19 B6 or (hl)
1114 6A1A 20 5D jr nz,ray22hit
1114 6A1C 2C inc l
1114 6A1D 24 inc h
1114 6A1E B6 or (hl)
1114 6A1F 20 58 jr nz,ray22hit
1114 6A21 24 inc h
1114 6A22 B6 or (hl)
1114 6A23 20 54 jr nz,ray22hit
1114 6A25 2C inc l
1114 6A26 24 inc h
1114 6A27 B6 or (hl)
1114 6A28 20 4F jr nz,ray22hit
1114 6A2A 24 inc h
1114 6A2B B6 or (hl)
1114 6A2C 20 4B jr nz,ray22hit
1114 6A2E 2C inc l
1114 6A2F 24 inc h
1114 6A30 B6 or (hl)
1114 6A31 20 46 jr nz,ray22hit
1114 6A33 24 inc h
1114 6A34 B6 or (hl)
1114 6A35 20 42 jr nz,ray22hit
1114 6A37 2C inc l
1114 6A38 24 inc h
1114 6A39 B6 or (hl)
1114 6A3A 20 3D jr nz,ray22hit
1114 6A3C 24 inc h
1114 6A3D B6 or (hl)
1114 6A3E 20 39 jr nz,ray22hit
1114 6A40 2C inc l
1114 6A41 24 inc h
1114 6A42 B6 or (hl)
1114 6A43 20 34 jr nz,ray22hit
1114 6A45 2C inc l
1114 6A46 24 inc h
1114 6A47 B6 or (hl)
1114 6A48 20 2F jr nz,ray22hit
1114 6A4A 24 inc h
1114 6A4B B6 or (hl)
1114 6A4C 20 2B jr nz,ray22hit
1114 6A4E 2C inc l
1114 6A4F 24 inc h
1114 6A50 B6 or (hl)
1114 6A51 20 26 jr nz,ray22hit
1114 6A53 24 inc h
1114 6A54 B6 or (hl)
1114 6A55 20 22 jr nz,ray22hit
1114 6A57 2C inc l
1114 6A58 24 inc h
1114 6A59 B6 or (hl)
1114 6A5A 20 1D jr nz,ray22hit
1114 6A5C 24 inc h
1114 6A5D B6 or (hl)
1114 6A5E 20 19 jr nz,ray22hit
1114 6A60 2C inc l
1114 6A61 24 inc h
1114 6A62 B6 or (hl)
1114 6A63 20 14 jr nz,ray22hit
1114 6A65 24 inc h
1114 6A66 B6 or (hl)
1114 6A67 20 10 jr nz,ray22hit
1114 6A69 2C inc l
1114 6A6A 24 inc h
1114 6A6B B6 or (hl)
1114 6A6C 20 0B jr nz,ray22hit
1114 6A6E 24 inc h
1114 6A6F B6 or (hl)
1114 6A70 20 07 jr nz,ray22hit
1114 6A72 2C inc l
1114 6A73 24 inc h
1114 6A74 B6 or (hl)
1114 6A75 20 02 jr nz,ray22hit
1114 6A77 24 inc h
1114 6A78 B6 or (hl)
1114 6A79 ray22hit
1114 6A79 67 ld h,a
1114 6A7A ED 5F ld a,r
1114 6A7C 6F ld l,a
1114 6A7D CB 3D srl l
1114 6A7F CB 3D srl l
1114 6A81 CB 3D srl l
1114 6A83 CB 3D srl l
1114 6A85 CB 3D srl l
1114 6A87 95 sub l
1114 6A88 CB 3D srl l
1114 6A8A CB 3D srl l
1114 6A8C CB 3D srl l
1114 6A8E 95 sub l
1114 6A8F 6F ld l,a
1114 6A90 E5 push hl
1114 6A91 0D dec c
1114 6A92 CA A5 A5 jp z,raycast_end
Вот приатачил старую глючную версию
https://jpegshare.net/images/e3/9b/e...4c22c0df8b.png
Ped7g, возможно ли сделать такой псевдооперанд
который есть в других, хороших:), асемблерах?)Код:CHK
The CHK directive causes a checksum to be computed and deposited at the current location. The starting point of the checksum calculation is indicated as an argument. Here is the format:
[label] .CHK starting_addr
Here is an example:
start: NOP
LDA #1
.CHK start
The checksum is calculated as the simple arithmetic sum of all bytes starting at the starting_addr up to but not including the address of the CHK directive. The least significant byte is all that is used.
Конечно, проггеры 80lvl могут и в LUA посчитать, но вот все же иногда КС нужен бывает и обычным "чайникам"
well, it's a possibility, then again the current macros allow you to create such functionality like this (with undocumented "read word" feature):
( tests/macro_examples/sum_checksum.asm ):
... so I'm rather thinking about documenting the `{}` operator finally, to make it official, as it can cover many similar cases.Код:; The CHK macro causes a checksum to be computed and deposited at the current location.
; The starting point of the checksum calculation is indicated as an argument.
;
; The checksum is calculated as the simple arithmetic sum of all bytes starting
; at the provided address up to but not including the address of the CHK macro instance.
; The least significant byte is all that is used.
;
; The macro requires the virtual DEVICE memory (checksum needs access to previously
; defined machine code bytes).
; CHK macro definition
MACRO .CHK address?
.SUM = 0 ; init values for checksumming
.ADR = address? ASSERT address? < $ ; starting address must be below current
DUP $ - address? ; do simple sum of all bytes
.SUM = (.SUM + {.ADR})&$FF
.ADR = .ADR + 1
EDUP
DB .SUM
ENDM
; Examples and verification (ZX Spectrum 48 virtual device is used for the test)
DEVICE ZXSPECTRUM48 : OUTPUT "sum_checksum.bin"
TEST1 DB 'A'
.CHK TEST1 ; expected 'A'
TEST2 DS 300, 'b'
DB 'B' - ((300*'b')&$FF) ; adjust checksum to become 'B'
.CHK TEST2 ; expected 'B'
TEST3 inc hl ; $23
inc h ; $24
.CHK TEST3 ; expected 'G' ($47)
The advantage of this solution is, that you can copy/paste it into your source now, and use it (no need to wait for new exe).
The disadvantage of this solution is, that it sort of destroys listing file (too much noise from DUP-EDUP).
Somebody can maybe provide also LUA version, which would be more kind to the listing, but I did want to verify that even macro-only solution is possible.
The native version in sjasmplus exe would be faster and preserve the listing file, but I'm not sure if it's worth of it (it feels a bit too specialized, it's not even very good checksum algorithm, although probably quite standard on ZX).
Is this macro sufficient solution for your needs? Or would LUA version suffice?
да это очень полезная вещь
ее всегда не хватало
теперь буду использовать повсеместно :)
печально что открытие {} произошло сразу после того
как я притулил {} себе для сворачиваемых комментариев в notepad++...
- - - Добавлено - - -
крайне неприятная особеность
Код:jp l1
jP l1
Jp l1
JP l1
l1 nop
Цитата:
SjASMPlus Z80 Cross-Assembler v1.13.1 (https://github.com/z00m128/sjasmplus)
Pass 1 complete (0 errors)
Pass 2 complete (0 errors)
1.asm(8): error: Unrecognized instruction: jP l1
1.asm(9): error: Unrecognized instruction: Jp l1
Pass 3 complete
Errors: 2, warnings: 0, compiled: 16 lines, work time: 0.000 seconds
Код:7 8000 C3 06 80 jp l1
1.asm(8): error: Unrecognized instruction: jP l1
8 8003 jP l1
1.asm(9): error: Unrecognized instruction: Jp l1
9 8003 Jp l1
10 8003 C3 06 80 JP l1
11 8006
12 8006
13 8006 00 l1 nop
Спасибо, хороший пример, но что-то в моем случае он считает неправильно :(((((((((
http://s1.micp.ru/R2u4v.jpg
справа - скомпилировано в TASM, слева - в SJAsm
по адресу 1Bh - контрольная сумма, как видно - разная, 79 - правильное число.
Считается с адреса 02h до адреса 1Ah включительно
About {} ... if you would read the sources (that's how I found it)... ;) (I think it was added already by Aprisobal back around first sjasmplus release)
About jp/Jp/jP/JP ... that's intentional choice of sjasmplus (I think it was decided maybe in original sjasm by Sj.M. himself)
instruction/directive must be all of the same case.
Labels/macros/defines are case sentitive.
I actually like it, because I use CamelCase for labels, so I have ~zero risk the assembler will pick one of them as instruction by accident.
But even if I would not like it, I don't think I would change one of the base choices of original sjasmplus, I don't "own" this project enough to introduce such massive change in behaviour.
в нашей отечественной ветке
https://github.com/sjasmplus/sjasmplus
уже пофикшено?
- - - Добавлено - - -
но когда правишь чужой код
у тебя появляются дополнительные проблемы
и это неудобно и раздражает
- - - Добавлено - - -
Код:SjASMPlus Z80 Cross-Assembler v.20190306.1
Pass 1 complete (0 errors)
Pass 2 complete (0 errors)
Pass 3 complete
Errors: 0, warnings: 0, compiled: 16 lines
для меток это может и нужно (Label labeL LabEL)Код:04 0000 org $8000
05 8000
06 8000
07 8000 C3 0C 80 jp l1
08 8003 C3 0C 80 jP l1
09 8006 C3 0C 80 Jp l1
10 8009 C3 0C 80 JP l1
11 800C
12 800C
13 800C 00 l1 nop
но не для инструкций явно нет
- - - Добавлено - - -
попробуй сгенерировать контрольную сумму для 2-х 3-х байт ($1,$2,$4)
и посмотри что не так
просмотри значения на каждом шаге
I don't understand... I see (from address 02 to 1A)
too lazy to do the full 8b math in head, but I see the low nibbles 9 + 8 + 3 + 1 + 8 + 3 + 1 = 33 mod 16 = 1Код:20 50 49 38 30 20
20 20 20 20 20 43 01 00
40 08 40 20 20 20 20 20
20 43 41
So the "9" in 79 doesn't make sense with "The checksum is calculated as the simple arithmetic sum of all bytes starting" - seems like some other formula is used in TASM.
Seems to me like XOR instead of add... let me try that.
https://github.com/z00m128/sjasmplus...m_checksum.asm
Yes, with XOR the result is $79.
Код:MACRO CHK address
.SUM = 0 ; init values for checksumming
.ADR = address ASSERT address < $ ; starting address must be below current
DUP $ - address ; do simple sum of all bytes
.SUM = (.SUM + {.ADR})&$FF
.ADR = .ADR + 1
EDUP
DB .SUM
display .SUM
ENDM
org $8000
l0
db $FF
db $01
db $02
CHK l0
Код:21 8000 01 db $01
22 8001 02 db $02
23 8002 04 db $04
24 8003
25 8003
26 8003
27 8003
28 8003 CHK l0
28 8003 07 > DB .SUM
Код:21 8000 FF db $FF
22 8001 01 db $01
23 8002 00 db $00
24 8003
25 8003
26 8003 CHK l0
26 8003 00 > DB .SUM
вполне себе правильно работаетКод:21 8000 FF db $FF
22 8001 01 db $01
23 8002 02 db $02
24 8003
25 8003
26 8003 CHK l0
26 8003 02 > DB .SUM
About jp/Jp/jP/JP ... well, there's the new `--syntax` option, which can be extended also to switch off instructions same-case sensitivity for particular piece of source, so I will look into it, how much difficult that would be.
But I don't want that "fix" as "default" at this moment (I may change my mind over time after thinking about it more, this is only telling you how I *feel* *now* = what you can expect in near future = no change or --syntax extension)
Ok, in future release (or you can already build from github current master) this will come:
"--syntax=i" to make instructions/directives case insensitive ... I was hoping to add also "I" option to uppercase all labels, but that's not possible without finally rewriting the labels implementation, would be too much mess and work in current source.
(BTW, I still think you should rather reformat the old source, shouldn't be that much hard... but the option will be available too)
"opt" will get two more commands "listoff, liston" to suspend listing file from source (for macros like CHKXOR to not fill listing with useless DUP looping)
"{address}" is now "official" (in documentation), and I added "{b address}" variant to read only BYTE.
(I have no idea yet, when "1.13.2" will happen, the 13.1 was just released, so I'm in no hurry, will give it probably 2-4 weeks = so this is just early-access info :) )
лично мне в sjasm/sjasmplus всегда не хватало библиотек, как это было, к примеру, у M80. Т.е. код чтобы собрать не в бинарь, а в некую либу, по мотивам всяких компиляторов си или тот же M80. А потом можно было бы прилинковывать из этой библиотеки функции/процедуры. Было бы удобно очень.