aGGreSSor(10.10.2025)
в древнейшей игре SabreWulf наткнулся на курьёзную ситуацию.
генератор псевдо-случайных чисел (в качестве начального отсчёта) использует значение из переменной (frames)
и всё бы ничего, но (frames) используется в `навешенной` защите (замеряется время между окончанием загрузки и стартом игры).
после проверки прерывания запрещены и игра стартует с фиксированным значением в (frames).
в итоге размещение ключевых предметов всегда одинаково.
(ситуация справедлива только для фирменной версии игры)
Titus(29.12.2025)
http://www.users.globalnet.co.uk/~jg...c/ys8708pp.zip
Кстати, вопрос оценки качества генератора так и остался открытым.Код:STAR TIP 3 (Random Number Generator) by Jon Ritman from Your Sinclair #20 (Aug.1987) [files STARTIP3.*] If you liked Head Over Heels and Batman, then you'll know that Jon Ritman, along with his partner Bernie Drummond, knows a thing or two about program- ming brilliant games. One of the most important things in a good arcade adventure, or so it seems, is a random number generator. "This is the 32-bit random number generator routine I used in Batman and Head Over Heels. The routine is quite fast and returns a reasonable random number. This version returns with HL holding a 16-bit random number. However, if you need all 32 bits, simply add the instruction LD DE,(SEED+2) just before the RET at the end. The 32-bit seed may be changed to any value of your choice." So here it is, for all of you assembly junkies, the listing, which can be located anywhere suitable in memory. For those of you that haven't got an assembler, there's also a hex dump of the code for you to load in via a suitable hex loader. For convenience we've assembled it to 30000 (7530 hex), and in case you're wondering, its length is 45 bytes. [It's actually 46 bytes. JimG] SEED: DB "Jon!" RANDOM: LD HL,(SEED+2) LD D,L ADD HL,HL ADD HL,HL LD C,H LD HL,(SEED) LD B,H RL B LD E,H RL E RL D ADD HL,BC LD (SEED),HL LD HL,(SEED+2) ADC HL,DE RES 7,H LD (SEED+2),HL JP M,RANDOM3 LD HL,SEED RANDOM2: INC (HL) INC HL JR Z,RANDOM2 RANDOM3: LD HL,(SEED) RET
Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)